In this part, only we will focus in Flex client, also there are others parts, such as J2EE components, but here we don’t consider here because they are out of scope of this blog. It includes to consider the following parts:
Create J2EE Web Proyect, it will contain the flex client created with Flex Builder or Flash Develop IDE .
- Create EJB Project , it references to the java project created in the 2nd part of this blog. Here, you’ll need to create a stateless session bean, and after to expose some method as Web Service. The NWDS has a wizard to do this taskes. Also, you could create a Web Services directly of the Java project by making use of the NWDS wizards.
- Create Flex Builder Project or FlashDevelop IDE, you create a flex client to consume the previuosly web services.
Create Enterprise Project; finally we will add the web and ejb project modules, previously created, to this kind project for deployment our ear file on SAP Netweaver AS 7.0. </li></ol><p> </p><p>Now, you will review the MXML file of our flex client (we will name FlexWebService.mxml). The main aspects of this file are the web services consumation, the treating of xml response from back end, and the datagrid flex component to show the data.</p><p>1. The web services part:</p><p><br /> </p><p> </p><p>In the wsdl attribute of the mx:WebService tag, we will put the wsdl url of the previously deployed web service.Also, in the tag mx:operation we mention the name of the method to call.</p><p>Note: We could consider to make use of the mx:HTTPService component with Servletes, but I have problems with the login sesion. SAP Netweaver AS has using the JASS login (user/password) module by default, then the Flex Client doesn’t save the jsession variable of the current logged user and therefore the HTTPService doesn’t work. May be by making use of flashvars we could integrate the SSO session on flex client (here some link of possible useful resource). </p><p>2. The treating of xml response from back end.</p><p><br />The response of the back-end need to be treat, then we write the actionscript method named </p><p><br />* private function resultHandler(event:ResultEvent):void*</p><p><br />This name is put on the “result” attribute of the mx:WebService attribute. Optionally, also we put on the “fault”attribute the name of the “faultHandler” function, in case of some error happen.</p><p>* private function faultHandler(event:FaultEvent):void
+</p><p>3. The datagrid flex component to show the data.</p><p><br />We will create an ArrayColletion variable (it needs to be Bindable) for to be used in the datagrid component.</p><p> </p><p>
private var myData:ArrayCollection=new ArrayCollection;</p><p> </p><p>This collection will containt the DTO (data transfer object) objects. this kind of object store the information from xml response. This collection containing the dto objects willbe used as data provider of the mx:Datagrid flex component.<br /><br /></p><p>+ <mx:DataGrid id=”campaignGrid”<br /> dataProvider=”*”You can download the Flex Builder project from here .