Service Invokers

Service Invokers (WebServiceInvoker, HTTPServiceInvoker, and RemoteObjectInvoker) let you create a service instance in the event sequence. This works great for small projects, prototyping and "I just need this service call" type of projects. As a best practice, however, all services should be defined in a separate file. This file can be called "Services.mxml" and be placed in its own services folder or in the business folder. In order to call one of those re-defined services, you can use the same tags (WebServiceInvoker, HTTPServiceInvoker, and RemoteObjectInvoker), but instead of defining all the specific properties (WSDL address, endpoint, etc), you simply use the instance attribute, specifying what already created service instance to use.

Using the instance attribute allows you to reuse services instead of defining them in your event handlers. You can create an instance of the services in your event map, and then reference it anywhere in your map:

<services:Services id="services" />
<RemoteObjectInvoker instance="{services.myService}" ... >

In order for this work, all services (RemoteObject, HTTPService or WebService) in your Services.mxml file must have an id assigned to them. You will then use that id when assigning an instance for your RemoteObjectInvoker, HTTPServiceInvoker or WebServiceInvoker tags.

For the above example, your Services.mxml file must contain a RemoteObject tag:

<mx:RemoteObject id="myService" ... />

No result and fault handlers are needed for this tag.

A sample Services.mxml file:

<?xml version="1.0" encoding="utf-8"?>
<mx:Object xmlns:mx="">
   <mx:RemoteObject id="myService" destination="ColdFusion" source="someCFC" />


As a middle-ground solution, you can also specify the service within your event map and reference to it by specifying the instance within the invoker tag.

For example, in your event map, you will have these two set of tags:

<mx:RemoteObject id="myService" ... />

<EventHandlers type="myEventType">
   <RemoteObjectInvoker instance="{myService}" ... >

10 responses

  1. Can your framework also be used with a LCDS dataservice?
  2. Hi Luc,
    If you mean the messaging part of LCDS, yes. See MessageHandlers
  3. No, I really ment using a as the service instead of RemoteObject. The DataService has also a destination property, result and faulthandlers. So I would think that it must be possible to integrate it in Mate. I am using Cairngorm at the moment and at least in that framework I can use both services.
  4. Hi Luc,
    No, that is not implemented. I too think it should be possible to integrate it with Mate.
    I couldn't find a whole lot of documentation on how it is used, so if you can provide a use case, it would help us evaluate how we can integrate it.
    By the way, these types of questions are better suited for the forums.

  5. I think that, dataservice cannot be integrated into mate, because that depend by lcds.swc, that need then included in project. Probably, someone, will make an extension for mate that leave to use DataService as service invoker.
    Same idea exist in Cairngorm, where exist two libs: Cairngorm.swc and CairngormEnterprise.swc
  6. If you want to display a small list of things coming from a call to the server, which option is the best pratcice?
    1. Let mate inject a service(remote object), so the as-class can call the specific method to get the list.
    2. Let mate call the specific method and inject the list, in response to an event thrown by the specific as-class/mxml who needs it.

    Option one seems very simple, option two is more complex, but seems more the mate way. Is this correct? What are the benefits of the second, more complex, option?

  7. Hi,

    What is your best practice for share one services.xml between some maps ?

  8. hey,
    i need to use web service in my application. but i (and flex builder allow this) wants to import all the WSDL data on "design time" to create strongly typed object. can i use this web service with mate? is it the same as using a webservice tag on a predefine instance?

  9. roee,
    The DelegateInvoker can be used for that. It was working on some beta version of Flex 4, but they may have changed something in the latest release.
  10. Hello,
    I'm new to Mate and to AS in general. I am trying pass a string to ColdFusion through the remoteobjectinvoker tag. Normally, this isn't a problem. However, I'm using ColdBox on the server and specifically the proxy class. It is expecting an argument collection that requires at least one string that it will pass as an event to call. The event handler will take care of all of the business logic. I'm not sure if I'm getting the syntax correct. Does anyone have an example they could share? The example that Luis Majano gives uses a delegate in flex to call the proxy. For my project, I'm trying to stay away from using any type of delegate and would rather use the mate provided tags.

Comments now closed