Introduction
In the previous article we see how a flex as3 can call webservice simply by using the Webservice class.
Let's see about webservice resultformat and data binding.
The Webservice Client Result Format in AS3
The webservice client result format can be "Object, xml, or e4x".
- The Object(default resultFormat) return data in form of ObjectProxy. ObjectProxy contains different datatypes like ArrayCollection etc. You would have to handle and parse this result obtaining the data you expect.
- XML format returns the data as an array of XMLNodes.
- E4X format gives an XMLList.
Link about result format: http://raghuonflex.wordpress.com/2007/04/05/e4x-my-1905/
But like jax-ws java client maked with netbeans wizard I wish to search about automatic data binding.
So I find this interesting article:http://livedocs.adobe.com/flex/3/html/help.html?content=data_4.html
It shows how make the proxy objects by using the wsdl.
This is done by flex builder ide.
Import Webservice into flex builder
The following link show the detailed steps
I write only some notes about this.
First of all, Import webservice inside flex builder project:
Data Menu -> Import Webservice and so on.
Then in order to call the webservice use the
NameService class.
Where Name is the name of webservice.
var ws:NameService = new NameService();
The autogenerate procedure make also one listener for each operation inside the webservice.
So add the listener and make the proper function called by the listener
ws.addOperation1EventListener(onResultOperation1);
the onResultOperation1 definition is like this:
private function onResultOperation1(res:Operation1ResultEvent):void{var value:Operation1ReturnType = res.result._return;
}
The Operation1ResultEvent and Operation1ReturnType is created by flexbuilder during the webservice import.
Note that Operation1ReturnType is the real return type used also in the webservice (server side).
So in this function you obtain directly the returnType Object.
Ok, for calling the webservice, first assign the request variable.
//inside costructor possible parameter to be pass to the webservice //operationvar param:Operation1_request = new Operation1_request();ws.Operation1_request_var = param;
call it
ws.Opearation1_send();
Conclusion
In this way more coding works is done automatic by the ide.
1 comment:
Post a Comment