Avatar

Correct answer by
Level 10

1) In Workbench ES2 create a process to create a new user. If you need to create a group there is also a service to create group. Create a short-lived process using the Avoka service > Create User operation. The Create User operation has the inputs depicted below.

p.png

2) Create a process variable called 'newUserXml' of type 'xml' and declare the variable as input. Ideally, create a schema for the xml.

3) The Create User operation has a single output, a string containing the user ID. Create a process variable called 'userID' of type 'string' and declare the variable as output.

3) Save, check-in, and deploy the process.

4) To test the process, invoke the process from the Workbench. For the input variable, plug data into an xml structure such as this...

<NewUser>

<Login/>

<Password/>

<CommonName/>

<CanonicalName/>

<Description/>

<Email/>

<Initials/>

<OrgName/>

<Address/>

<Telephone/>

</NewUser>

5) If the test succeeds, you are ready to create the Flex application. If not, figure out why.

6) Build a Flex app. Once you deployed the process, the remoting endpoint is automatically created and can be accessed by Flex. Here is a stub.

<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="initChannelSet()">


<mx:Script>

<![CDATA[


import mx.messaging.channels.AMFChannel;

import mx.messaging.ChannelSet;

import mx.rpc.events.ResultEvent;

import mx.rpc.events.FaultEvent;


private function initChannelSet():void {

var cs:ChannelSet= new ChannelSet();

cs.addChannel(new AMFChannel("my-amf","http://localhost:8080/remoting/messagebroker/amf"));

ro.channelSet = cs;

}


private function submitRequest():void {

var newUser:XML = new XML(getXmlData());

ro.setCredentials("administrator","password");

ro.invoke({newUserXml:newUser});

}


private function remotingResultHandler(event:ResultEvent):void {

var userID:String = event.result.userID;

...

}


private function remotingFaultHandler(event:FaultEvent):void {

Alert.show(event.fault.faultDetail.toString());

}


private function getXmlData():String {

var xmlStr:String = "<NewUser>"

  + "<Login>" + login.text + "</Login>"

  + "<Password>" + password.text + "</Password>"

  + "<CommonName>" + commonName.text + "</CommonName>"

  ....

  + "</NewUser>>";

  return (xmlStr);

}


]]>

</mx:Script>


<mx:RemoteObject id="ro" destination="MyApplication/processes/CreateNewUser"

   result="remotingResultHandler(event)" fault="remotingFaultHandler(event)"/>


<mx:VBox>


   UI goes here...


   <mx:Button label="Submit" click="submitRequest()"/>


</mx:VBox>


</mx:Application>

Steve

View solution in original post