View comments | RSS feed
Packagemx.rpc.soap.mxml
Classpublic dynamic class WebService
InheritanceWebService Inheritance WebService Inheritance AbstractService Inheritance Proxy Inheritance Object
ImplementsIMXMLObject, IMXMLSupport

The <mx:WebService> tag gives you access to the operations of SOAP-compliant web services.

MXML Syntaxexpanded Hide MXML Syntax

The <mx:WebService> tag accepts the following tag attributes:

 <mx:WebService
   Properties
   concurrency="multiple|single|last"
   destination="No default."
   id="No default."
   serviceName="No default."
   showBusyCursor="false|true"
   makeObjectsBindable="false|true"
   useProxy="false|true"
   wsdl="No default."
    Events
   fault="No default."
   result="No default."
 />
 

An <mx:WebService> tag can have multiple <mx:operation> tags, which have the following tag attributes:

 <mx:operation
   Properties
   concurrency="multiple|single|last"
   name=No default, required.
   resultFormat="object|xml|e4x"
   makeObjectsBindable="false|true"
    
   Events
   fault=No default.
   result=No default.
 />
 
An <mx:Operation> tag contains an <mx:request> tag. To specify an XML structure in an <mx:request> tag, you must set the value of the tag's format attribute to "xml". Otherwise, the body is converted into Objects.

View the examples.

See also

Using RPC Components


Public Properties
 PropertyDefined by
 InheritedchannelSet : ChannelSet
Provides access to the ChannelSet used by the service.
AbstractService
  concurrency : String
Value that indicates how to handle multiple calls to the same service.
WebService
 Inheritedconstructor : Object
A reference to the class object or constructor function for a given object instance.
Object
 Inheriteddescription : String
The description of the service for the currently active port.
WebService
 Inheriteddestination : String
The destination of the service.
WebService
 InheritedendpointURI : String
The location of the WebService.
WebService
 Inheritedheaders : Array
Returns the array of SOAPHeaders registered for the WebService.
WebService
 InheritedmakeObjectsBindable : Boolean
When this value is true, anonymous objects returned are forced to bindable objects.
WebService
 Inheritedoperations : Object
The Operations array is usually only set by the MXML compiler if you create a service using an MXML tag.
AbstractService
 Inheritedport : String
Specifies the port within the WSDL document that this WebService should use
WebService
 Inheritedprototype : Object
[static] A reference to the prototype object of a class or function object.
Object
 InheritedrequestTimeout : int
Provides access to the request timeout in seconds for sent messages.
AbstractService
 InheritedrootURL : String
The URL that the WebService should use when computing relative URLs.
WebService
 Inheritedservice : String
Specifies the service within the WSDL document that this WebService should use.
WebService
  serviceName : String
WebService
  showBusyCursor : Boolean
If true, a busy cursor is displayed while a service is executing.
WebService
 InheriteduseProxy : Boolean
Specifies whether to use the Flex proxy service.
WebService
 Inheritedwsdl : String
The location of the WSDL document for this WebService.
WebService
Public Methods
 MethodDefined by
  
WebService(destination:String = null)
Creates a new WebService component.
WebService
 Inherited
Adds a header that will be applied to all operations of this web service.
WebService
 Inherited
addSimpleHeader(qnameLocal:String, qnameNamespace:String, headerName:String, headerValue:String):void
Add a header that will be applied to all operations of this WebService.
WebService
 Inherited
Returns a Boolean value that indicates whether the WebService ready to load a WSDL (does it have a valid destination or wsdl specified).
WebService
 Inherited
Clears the headers that applied to all operations.
WebService
 Inherited
Disconnects the service's network connection and removes any pending request responders.
AbstractService
 Inherited
getHeader(qname:QName, headerName:String = null):SOAPHeader
Returns a header if a match is found based on QName localName and URI.
WebService
 Inherited
Returns an Operation of the given name.
AbstractService
 Inherited
Indicates whether an object has a specified property defined.
Object
  
initialized(document:Object, id:String):void
Called automatically by the MXML compiler if the WebService is setup using a tag.
WebService
 Inherited
Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter.
Object
 Inherited
loadWSDL(uri:String = null):void
Instructs the WebService to download the WSDL document.
WebService
 Inherited
Logs the user out of the destination.
AbstractService
 Inherited
Indicates whether the specified property exists and is enumerable.
Object
 Inherited
removeHeader(qname:QName, headerName:String = null):void
Removes the header with the given QName from all operations.
WebService
 Inherited
setCredentials(username:String, password:String):void
Set the credentials for the destination accessed by the service.
AbstractService
 Inherited
Sets the availability of a dynamic property for loop operations.
Object
 Inherited
setRemoteCredentials(remoteUsername:String, remotePassword:String):void
The username and password to authenticate a user when accessing the webservice.
WebService
 Inherited
Represents an instance of WebService as a String, describing important properties such as the destination id and the set of channels assigned.
WebService
 Inherited
Returns the primitive value of the specified object.
Object
Protected Methods
 MethodDefined by
 Inherited
callProperty(name:*, ... rest):*
Overrides the behavior of an object property that can be called as a function.
Proxy
 Inherited
Overrides the request to delete a property.
Proxy
 Inherited
Overrides the use of the descendant operator.
Proxy
 Inherited
getProperty(name:*):*
Overrides any request for a property's value.
Proxy
 Inherited
Overrides a request to check whether an object has a particular property by name.
Proxy
 Inherited
Checks whether a supplied QName is also marked as an attribute.
Proxy
 Inherited
Allows enumeration of the proxied object's properties by index number to retrieve property names.
Proxy
 Inherited
Allows enumeration of the proxied object's properties by index number.
Proxy
 Inherited
nextValue(index:int):*
Allows enumeration of the proxied object's properties by index number to retrieve property values.
Proxy
 Inherited
setProperty(name:*, value:*):void
Overrides a call to change a property's value.
Proxy
Events
 EventSummaryDefined by
 Inherited The fault event is dispatched when a service call fails and isn't handled by the Operation itself.AbstractService
 Inherited The invoke event is dispatched when a service Operation is invoked so long as an Error is not thrown before the Channel attempts to send the message.AbstractService
 Inherited The LoadEvent.LOAD is dispatched when the WSDL document has loaded successfully.WebService
 Inherited The result event is dispatched when a service call successfully returns and isn't handled by the Operation itself.AbstractService
Public Constants
 ConstantDefined by
 InheritedDEFAULT_DESTINATION_HTTP : String = "DefaultHTTP"
[static]
WebService
 InheritedDEFAULT_DESTINATION_HTTPS : String = "DefaultHTTPS"
[static]
WebService
Property detail
concurrencyproperty
public var concurrency:String

Value that indicates how to handle multiple calls to the same service. The default value is multiple. The following values are permitted:

serviceNameproperty 
serviceName:String  [read-write]Implementation
    public function get serviceName():String
    public function set serviceName(value:String):void
showBusyCursorproperty 
showBusyCursor:Boolean  [read-write]

If true, a busy cursor is displayed while a service is executing. The default value is false.

Implementation
    public function get showBusyCursor():Boolean
    public function set showBusyCursor(value:Boolean):void
Constructor detail
WebService()constructor
public function WebService(destination:String = null)

Creates a new WebService component.

Parameters
destination:String (default = null) — the destination of the WebService, should match a destination name in the services-config.xml file.
Method detail
initialized()method
public function initialized(document:Object, id:String):void

Called automatically by the MXML compiler if the WebService is setup using a tag. If you create the WebService through ActionScript you may want to call this method yourself as it is useful for validating any arguments.

Parameters
document:Object — the MXML document on which this WebService lives
 
id:String — the id of this WebService within the document
Examples
WebServiceExample
<?xml version="1.0"?>
<!-- Simple example to demonstrate the WebService tag. -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">

<!--  Make sure the Flex Data Services proxy-config.xml file contains the following definition: 

    <destination id="DefaultHTTP">
        <properties>
            <dynamic-url>http://ws.invesbot.com/*</dynamic-url>
        </properties>
    </destination>
-->

    <mx:Script>
        <![CDATA[
            import mx.controls.Alert;        
        ]]>    
    </mx:Script>

    <mx:WebService id="WS" wsdl="http://ws.invesbot.com/stockquotes.asmx?WSDL"
        useProxy="true"
        fault="Alert.show(event.fault.faultstring), 'Error'">

        <mx:operation name="GetQuote" resultFormat="object">
            <mx:request>
                <symbol>{stockSymbol.text}</symbol>
            </mx:request>
        </mx:operation>
    </mx:WebService>

    <mx:Panel title="WebService Example" height="75%" width="75%" 
        paddingTop="10" paddingBottom="10" paddingLeft="10" paddingRight="10">

        <mx:Label width="100%"  color="blue"
            text="Enter a stock symbol to obtain a quote."/>

        <mx:TextInput id="stockSymbol" text="ADBE"/>
        <mx:Button label="Get Quote" click="WS.GetQuote.send()"/>

        <mx:Text htmlText="Company: {WS.GetQuote.lastResult.GetQuoteResult.StockQuote.Company}"/>
        <mx:Text htmlText="Current price: ${WS.GetQuote.lastResult.GetQuoteResult.StockQuote.Price}"/>

    </mx:Panel>    
</mx:Application>




Comments


mpeterson said on Jun 30, 2006 at 12:20 PM :
Instances of "faultstring" on this page should be "faultString".
- Mike Peterson
Adobe Flex documentation team
No screen name said on Mar 30, 2007 at 11:13 AM :
If you connect to the same webService twice in one flash app you are likely to get weird timing errors. I kept getting WSDL.BadElement errors every few time I ran my App.

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flex/2/langref/mx/rpc/soap/mxml/WebService.html