This content has been marked as final. Show 9 replies
The Import WebServices wizard creates a strong-typed representation of the service. It generates .as files for each complex type defined in the WSDL, as well for each request wrapper.
For a simple example on how to use the generated code you should look inside the folder where the classes were generated and open the .as file with the same name as you specified for the webservice in the wizard UI. On top of the file there is a comment area with some sample code (albeit non-functioning, as it does not contain real values, but placeholders).
Basically, what you need to do is follow these steps:
1. Add an import statement in your mxml file for the generated classes, e.g. import com.mypackage.*;
2. Create an instance of the webservice. You need to know the name of the main class, as you specified it in the wizard UI. e.g. public var myService:MyMainClassName = new MyMainClassName
3. look around on what the code hint provides for the myService variable. You will find the actual operation, with the same name as in the wsdl, as well as methods to add the event handlers. The naming convention for this is: addOperationNameEventListener().
4. Create a method that takes a typed result event parameter (the one generated for the target operation) and which will handle the incoming operation result.
5. Call your operation - like this:myService.operationName(inputParams).
I will try to post a real-life example, with a full application in a while, but the main steps are the ones above.
Hope this helps,
Thanks for the tips, all of that does make perfect sense... but as soon as I create the instance of the webservice errors show up in the problems tab coming from the generated actionscript file (the main one from the webservice). Specifically these three errors pop up, please let me know if you have any tips:
1046: Type was not found or was not a compile-time constant: GetListSoapOutResultEvent. Test/src/generated/webservices Lists.as line 120 1191645165421 822
1120: Access of undefined property GetListSoapOutResultEvent. Test/src/generated/webservices Lists.as line 112 1191645165421 821
1180: Call to a possibly undefined method GetListSoapOutResultEvent. Test/src/generated/webservices Lists.as line 120 1191645165421 823
I can attach the generated .as file if that will help.
I am also using the Import Web Service wizard. For very simple cases it works but for web services where it receives a complex wsdl type I got the following error:
TypeError: Cannot unmarshall type ' http://www.w3.org/2001/XMLSchema::ServiceUsageArray' from XML.
at mx.rpc.xml::SchemaMarshaller/unmarshall()[E:\dev\flex_3_beta2\sdk\frameworks\projects\rpc \src;mx\rpc\xml;SchemaMarshaller.as:124]
at mx.rpc.xml::SchemaManager/unmarshall()[E:\dev\flex_3_beta2\sdk\frameworks\projects\rpc\sr c;mx\rpc\xml;SchemaManager.as:368]
at mx.rpc.xml::XMLDecoder/marshallBuiltInType()[E:\dev\flex_3_beta2\sdk\frameworks\projects\ rpc\src;mx\rpc\xml;XMLDecoder.as:1612]
at mx.rpc.xml::XMLDecoder/decodeType()[E:\dev\flex_3_beta2\sdk\frameworks\projects\rpc\src;m x\rpc\xml;XMLDecoder.as:1540]
at mx.rpc.soap::SOAPDecoder/decodeType()[E:\dev\flex_3_beta2\sdk\frameworks\projects\rpc\src ;mx\rpc\soap;SOAPDecoder.as:617]
at mx.rpc.xml::XMLDecoder/decode()[E:\dev\flex_3_beta2\sdk\frameworks\projects\rpc\src;mx\rp c\xml;XMLDecoder.as:154]
at mx.rpc.soap::SOAPDecoder/mx.rpc.soap:SOAPDecoder::decodeBody()[E:\dev\flex_3_beta2\sdk\fr ameworks\projects\rpc\src;mx\rpc\soap;SOAPDecoder.as:426]
at mx.rpc.soap::SOAPDecoder/mx.rpc.soap:SOAPDecoder::decodeEnvelope()[E:\dev\flex_3_beta2\sd k\frameworks\projects\rpc\src;mx\rpc\soap;SOAPDecoder.as:270]
at mx.rpc.soap::SOAPDecoder/decodeResponse()[E:\dev\flex_3_beta2\sdk\frameworks\projects\rpc \src;mx\rpc\soap;SOAPDecoder.as:211]
at com.me::BaseMeService/com.me:BaseMeService::processResult()[C:\Workspaces\Adobe\Flex3\FID S\src;com\me;BaseMeService.as:230]
at mx.rpc::AsyncResponder/result()[E:\dev\flex_3_beta2\sdk\frameworks\projects\rpc\src;mx\rp c;AsyncResponder.as:73]
at mx.rpc::AsyncRequest/acknowledge()[E:\dev\flex_3_beta2\sdk\frameworks\projects\rpc\src;mx \rpc;AsyncRequest.as:81]
at DirectHTTPChannel.as$136::DirectHTTPMessageResponder/completeHandler()[E:\dev\flex_3_beta 2\sdk\frameworks\projects\rpc\src;mx\messaging\channels;DirectHTTPChannel.as:381]
We have seen this happen when an unsupported port is selected in the wizard. The introspection and the SDK do not fully support SOAP 1.2 and do not support using HTTP GET/POST ports from inside a WSDL file. Please make sure that you have selected the SOAP 1.1 port.
If this is not the problem, please attach the wsdl file that causes this issues. This will help us better identify the problem and find a fix for it faster.
It seems that the SDK XML encoder does not manage to serialize the generated complex type properly. There is a known bug when serializing a complex type that contains as members simple types that are restrictions for basic types. A fix for this is under way, but in order to make sure that this is the same case, please attach the wsdl file with your next post.
Thanks for your answer.
I attached my wsdl. By the way I am using Soap 1.1.
I cannot reproduce this bug because I cannot call the actual service endpoint (it is on your local machine). Is there a public facing endpoint for this service with which I can test?
I can't open my webserver to the outside world but its the basic Microsoft Windows SharePoint Services that are available for free. I can attach the WSDL file to this reply. If you guys can figure out what the problem is and facilitate Flex interacting with Sharepoint, it could be an excellent avenue for many enterprise RIA apps. The main method I am trying to reach is GetList.
P.s. Forum won't let me attach the WSDL, here is a link:
I am having difficulty on exposing my web service to outside at this stage (I am working on it though). By the way when is the expected fix going to be released ? Is there a way to access it now and test my stuff on it ?