(This tag must be placed inside an <EventHandlers> tag or a <MessageHandlers> tag)

The WebServiceInvoker tag allows you to create a Web Service (mx.soap.WebService) in your handlers list and call a method on that web service, in one step. To use this tag, you need to specify its wsdl attribute that will determine the address of the webservice. You also need to specify the method to call. In addition to those two, this tag will accept all mx.rpc.soap.WebService tag attributes (with the exception of xmlSpecialCharsFilter and operations).

	arguments="{['argument1', 'argument2']}" />

The above example would be the same as doing the following:

<mx:WebService id="myServiceInstance" wsdl="/myservices/myService.cfc?wsdl">

myServiceInstance.serverMethodToCall('argument1', 'argument2');

You would also need to either create event handlers for the server result and fault or create a Responder to handle them. That is not necessary when using the WebServiceInvoker tag.

See section "Handling a service result or fault".

With this tag, you can also utilize an already created WebService instance. This is useful when the same services are used by several EventHandlers blocks or when using multiple event maps.

Suppose you have a WebService tag (either in the event map itself or in a different file):

<mx:WebService id="myServiceInstance" wsdl="/myservices/myService.cfc?wsdl">

You can call a method on that already created service as follows:

<WebServiceInvoker instance="{myService}" method="serverMethodToCall" />



required if no instance is specified

This attribute specifies the address for the WebService definition file. Refer to mx.rpc.soap.WebService documentation for more information.



The method attribute specifies what function to call on the web service instance.


If the remote method has arguments, you can pass them via the "arguments" attribute.

Suppose you have a WebService method called getPhotos and it expects a user name and an album name as arguments. You can specify them with the arguments attribute:

	arguments="{['Tom','My Album']}" />

Note that the arguments attribute expects an array. Besides passing literal values, you can pass values coming from the event that triggered the list of handlers to execute:

	arguments="{[event.userName, event.album]}"/>

This assumes that the event contained a userName property and an album property.

You can also pass the complete data or lastReturn as an argument depending on what your service expects.


Of course you can use any combination of arguments:

	arguments="{[event.age, lastReturn, 'Tom']}"/>


A WebService instance

The instance attribute specifies the already created service instance to use to make the call. This attribute must be supplied using bindings because it needs to point to an already created object.

Suppose you have a WebService already created:

<mx:WebService id="myServiceInstance" wsdl="/myservices/myService.cfc?wsdl">

You can make a call to this service by using the WebServiceInvoker tag, with instance {myService}. Note that any property you need for your service must be defined in the WebService tag.

<WebServiceInvoker instance="{myService}" method="getPhotos" />



Whether to show debugging information for this WebServiceInvoker resultHandlers and faultHandlers. If true, Console output will show debugging information as those handlers run.

Inner tags


A set of handlers to run when the server call returns a result. Inside this inner tag, you can use the same tags you would in the main body of an <EventHandlers> block, including other service calls.


A set of handlers to run when the server call returns a fault. Inside this inner tag, you can use the same tags you would in the main body of an <EventHandlers>, including other service calls.

Handling a service result or fault

Just like all the "service invoker" tags, you can have a resultHandlers block and a faultHandlers block inside the tag to handle service results and faults.

	arguments="{['argument1', 'argument2']}" >

		... this list executes when server returns results ...
		... this list executes when server returns an error ...


See "Handling a service result or fault" for more information.

17 responses so far

  1. OK, how do we send the data back from a web service (ColdFusion cfc). None of your examples spell this one out. (It also is not obvious to me yet how I can look at the debug output of the web service return using Mate.)
  2. Hi John,
    You receive the data sent by the service using the eventHandlers inner tag (or are you asking how to send data from CF to Flex?). See page Handling a service result or fault. Also, most of the examples in the Examples page show how to get data coming from a service. The stock quotes example even uses a web service.
    Regarding your other question, see the "debug" attribute description.
  3. Hi!

    I've just started using Mate in a small project. Seems really nice for making reusable components.

    Using Fiddler I've discovered that the wsdl is loaded before every webservice call. Am I doing something wrong or is this intentional?

  4. Hi again!

    Another question: I have a web service which takes a complex object as input. Is it possible to use the webserviceinvoker to pass in such an object to the server?

    It seems that it can only handle simple arguments like {[event.username, event.password]}.

    If I pass in something like {[event.complexObject]} it seems that it will not get serialized properly.
  5. Hi Hakon,
    Did you also try having a <mx:WebService> instance instead of declaring the service within the tag? ie:
    <WebServiceInvoker instance="{myService}" method="getPhotos" />
  6. hakon,
    We followed the docs when calling the service, and they tell to call loadWSDL(). It seems though, that when they do that with the WebService tag, they do not call loadWSDL each time. So we'll have to make a check before attempting to load it.
    Regarding your other question, how do you normally pass that object (without Mate)?
  7. what about JSON support?
  8. Robert,
    The 3 service tags in Mate match the 3 Flex tags (RemoteObject, WebService, and HTTPService).
    JSON requests are normally made using the HTTPService tag, therefore you would use the HTTPServiceInvokere tag in Mate. You could then do the parsing in the resultHandlers using MethodInvoker.

    Having the http request and the parsing in one step would make a nice extension though.
  9. Hi, i have same problem with hakon, i've used WebServiceInvoker with instance from already created WebServices flex component, but it always reload WSDL every I call WebService method, Please give me suggestion to solve this
  10. Hi,<br />all right, but wich argument can i pass trough the faultHandler for getting more information, whats getting wrong.<br />similar to the faultEvent of Webservice and the FaultEvent from FlexFramework.

Leave a response

If you need help or want to comment on something not related to this page, please post in the forums. Thanks!

Leave this field empty