![]() | ![]() ![]() ![]() |
![]() | |
![]() | |
![]() |
The WebServiceConnector component enables you to access remote methods exposed by a server using the industry-standard SOAP (Simple Object Access Protocol) protocol. A web service may accept parameters and return a result. Using the Flash MX Professional 2004 authoring tool and the WebServiceConnector component, you can introspect, access, and bind data between a remote web service and your Flash application. A single instance of a WebServiceConnector component can be used to make multiple calls to the same operation. To call more than one operation, though, you need to use a different instance of a WebServiceConnector component for each operation.
A web service's methods (sometimes referred to as operations) are defined by a Web Service Description Language (WSDL) file. The WSDL file specifies a list of operations, parameters, and results (referred to as a schema) that are exposed by the web service.
WSDL files are accessible using a URL. In Flash MX Professional 2004, you can view the schema of any web service by entering the URL for its WSDL file using the Web Services panel. Once you identify a WSDL file, the web service is available to any application you create.
Note: Keep in mind that access to a web service (as with any external data) is subject to Flash Player security features. See About data connectivity and security in Flash Player (Flash Professional only).
For more information on the WebServiceConnector component, including its properties, methods, and events, see WebServiceConnector (Flash Professional only) (you may need to update your Help system to see this information).
The following are the WebServiceConnector component parameters:
operation A string that is the name of a method of the web service. In the authoring UI, this appears as a pop-up menu, which is updated any time you change the WSDLURL.
multipleSimultaneousAllowed A Boolean value; when this parameter is set to true
, it allows a trigger()
operation to initiate when another trigger()
operation is already in progress. Multiple simultaneous trigger()
operations might not be completed in the same order they were called. Also, Flash Player may place limits on the number of simultaneous network operations. This limit varies by version and platform. When the parameter is set to false
, a trigger()
operation cannot initiate if another one is in progress.
suppressInvalidCalls A Boolean value; when this parameter is set to true
, it suppresses the trigger()
operation if the data parameters are invalid. When it is set to false
, the trigger()
operation executes and uses invalid data if necessary.
WSDLURL A string that is the URL of a web service WSDL file.
The typical workflow for the WebServiceConnector component is as follows.
Note: The schema for the params
and results
component properties is updated each time the author changes the WSDLURL
or operation
parameter. This overwrites any settings that you have edited.
The schema for a web service is defined through its WSDL file. Flash MX Professional 2004 has built-in support for introspecting a WSDL and generating the schema.
The following example demonstrates how to view the schema for a web service.
Note: This example requires an active Internet connection, because it uses a public web service. If you use a web service in your application, the web service must be located in the same domain as the SWF file for your application in order for the application to work in a web browser. See Applications and web services.
http://www.xmethods.net/sd/2001/BabelFishService.wsdl
This is a schematic representation of the service that you are calling. The parameters as well as result structure are defined within the schema. This schema states that the BabelFish Service expects two string parameters when it is called and will return a string as the result of the call.
The items identified within the schema can now be bound to a variety of UI controls to provide values for the parameters or to display the results of the web service.
Many developers are interested in using an industry standard such as SOAP web services as the data-exchange mechanism between their client and server. One reason this approach is gaining favor is the increasing number of popular servers that support exposure of logic using SOAP.
However, there may be cases where you want the client software to consume web services that are published by third parties or hosted on servers that fall outside the Flash Player sandbox. There are several ways to make this work, while still preserving the end-user security and privacy that the Flash Player sandbox provides. These approaches involve the creation of an intermediary object that resides on the server to act as a bridge between your client and the public services you want to consume. This approach offers several advantages:
Many of the SOAP-based applications that you build will consume private web services hosted on your server. Once you have determined the best way to implement and expose your own web services, it is easy to make public web services available to your client application. When you are in control of the server, you can offer a complete solution. The server is the ideal place for business logic that can determine the best way to respond to requests for data and the results that should be sent back to the client. This is also the most secure way to build an application. The server can provide additional processing to make sure that users have access only to certain services as well as protect the client from making calls to malicious services that can return bad data. See About data connectivity and security in Flash Player (Flash Professional only).
When the WebServiceConnector component receives multiple records of data from a web service, it translates them into an ActionScript array so that they are accessible within your application. Translating multiple records of data from XML/SOAP into ActionScript native data can be a very time-consuming process (large arrays can take seconds, or tens of seconds). The WebServiceConnector component supports a feature called lazy decoding, which defers this translation. Therefore, result values that are arrays are not immediately translated from XML to ActionScript. Instead, the result value passed to the user is a special object that acts similarly to an array and translates the XML data only when it is actually requested. You request the data by using the command myArray[myIndex]
. The net effect of this feature is to improve the perceived performance of web services by spreading the workload over a longer period of time.
Note: The result value can be accessed only by using the myArray[myIndex]
syntax. It cannot be accessed using a for..in loop such as for (var i in myArray)
.
![]() | |
![]() | |
![]() | |
![]() ![]() ![]() |