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:

[Bindable] private var services:Services = new 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="http://www.adobe.com/2006/mxml">
   
   <mx:RemoteObject id="myService" destination="ColdFusion" source="someCFC" />

</mx:Object>

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}" ... >
</EventHandlers>

4 responses so far

  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 mx.data.mxml.DataService 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.

    Thanks!

Leave a response

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