There are two ways of calling web service operations in Adobe Flex:
- Use Flex built-in WebService class
- Use web service proxy classes (automatically generated by WSDL Instrospection Wizard)
Using Flex Built-In WebService Class
Using the first approach, you can set endpointURI on the WebService instance. The creationComplete event is thrown when the application is initialized. In this case, you can attach a listener (i.e., initApp()) to intercept the event and set the correct endpointURI on the WebService instance. Note that the new endpointURI set on the WebService instance applies to all operations defined in it.
<?xml version="1.0" encoding="utf-8"?>
<mx:operation name="doSimpleSearch" resultFormat="XML"
<mx:operation name="login" resultFormat="XML"
private function initApp():void
Using Web Service Proxy ClassesYou can also use the Flex Builder Import Web Service feature to automatically generate connection code for invoking SOAP-based web service operations. The generated code includes client-side (ActionScript) web service proxy classes that return strongly typed objects. You can use the generated code to call web service operations directly and to pass strongly typed objects as operation parameters.
Generated web service proxy files
The Import Web Service feature introspects a provided WSDL file and generates the following ActionScript class files:
For example, our service is named SearchService which is retrieved from the WSDL file. Using Import Web Service feature in FlexBuilder, it generates the following files:
BaseSearchServicePort.endpointURI = "http://myserver:7777/search/query/Search"
This should work when you use the generated code to call web service operations directly. Without this fix, you will get the notorious stream error #2032.
I also noticed that there is a generated WSDL file in the project under .wsdl folder. It may be a good idea to change the URL in that WSDL file to be correct.