There are exceptions to the types of SOAP web services Flash can consume. Flash only supports SOAP-based web services when they are transported over the HTTP protocol. Flash does not support SOAP web services over SMTP or FTP as of this release.
Flash also does not support web services with non-SOAP ports, such as MIME. The name attribute within the port element must point to a SOAP port. In the excerpt from the service definition of a WSDL document below, the port that bears the name SamplePort must be a SOAP port.
<service name="SampleService">
<port name="SamplePort">
<soap:address location="http://sample.com/SampleService"/>
</port>
</service>
Flash also does not support the import tag. You can use
the import tag to keep parts of a WSDL description in separate
files. You can reuse those parts, such as schemas and other definitions.
Flash MX Professional 2004 does not support web services that use the
import tag.
You may also run into problems with web services that require complex data, such as objects containing arrays, as an input parameter. If you try to pass complex data to a web service using the WebService API, you will receive an error saying that the endpoint URL could not be opened. To send complex data, use Flash Remoting. Complex data in output parameters, on the other hand, does not cause any problems.
This is probably pretty obvious, but I'll point it out anyway: Flash does not support web services that return data it can't handle, such as highly formatted HTML. If a web service returns an interactive HTML map, for example, Flash will not be able to render it correctly due to the limitations of its HTML capabilities. On the other hand, if the web service returns simply the building blocks for an interactive map, such as an XML structure describing label strings, the URLs of image files, and so on, Flash, with some effort, can recreate the map.
Finally, there are some types of web services that the WebService API supports that will fail if you use the WebServiceConnector component. The WebServiceConnector does not support web services with more than one SOAP port defined in the WSDL. The WSDL excerpt below defines a service with two SOAP ports.
<service name="SampleService"> <port binding="tns:Service1" name="Service1"> <soap:address location="http://samplesite.com/SampleService" /> </port> <port binding="tns:Service1" name="Service2"> <soap:address location="http://samplesite.com/SampleService" /> </port> </service>
If you try to invoke this type of web service with the WebServiceConnector, the compiler will throw an error: "There are multiple possible ports in the WSDL file; please specify a service name and port name!" The call fails because the WebServiceConnector API doesn't allow the developer to specify the port. When there is only one port, this does not become an issue.
Even though this is undocumented, the WebService API provides a workaround for handling multiple ports.
// instantiate the WebService object
var ws:WebService = new WebService('http://sampleWSDL.wsdl');
// specify the port name
ws._portName = 'Service1';
// call an operation on the service
ws.getInfo('94103');
The example consumes a fictitious web service named Sample Service,
which defines an operation named getInfo.
If you use the code above, the web service call will no longer fail because
it specifies the port. Note that this code requires the WebServiceClasses to
be in your movie's library. Select Other Panels > Common Libraries > Classes
and drag the WebServiceClasses compiled clip into the library of your Flash
file.
The WebServiceConnector component also does not support web services with more than one service defined in the WSDL. Web services with more than one service often have more than one SOAP port as well, since each service element in the WSDL contains a port element. Here is an excerpt from a WSDL description that describes a web service with more than one service:
<service name="SampleService"> <port binding="tns:SampleService" name="SampleService"> <soap:address location="http://samplesite.com/SampleService" /> </port> </service> <service name="AnotherService"> <port binding="tns:AnotherService" name="AnotherService"> <soap:address location="http://samplesite.com/AnotherService" /> </port> </service>
Each service usually encompasses several operations. When you add the URL of the WSDL description of a web service with more than one service to the Web Services panel, Flash only parses the first service and its operations and displays them in the panel. This is because the Web Services panel only supports web services with exactly one service. The Web Services panel doesn't display more than one service per WSDL.
If you call one of the web services of a multiservice definition using the WebServiceConnector component, the compiler reports the same multiple ports error mentioned above. Again, there is an undocumented workaround through the WebService API. If you use this API to specify the service name and port name (as shown in the following code), the web service call will succeed.
import mx.services.* ;
// instantiate the WebService object
var ws:WebService = new WebService('http://sampleWSDL.wsdl');
// specify the service name
ws._name = 'SampleService';
// specify the port name
ws._portName = 'Service';
// call an operation on the service
ws.invokeMethod('94103');
Note: This code requires the WebServiceClasses to be in the library of your Flash file. Select Other Panels > Common Libraries > Classes and drag the WebServiceClasses compiled clip into the Library panel.