View comments | RSS feed
(Adobe® Flex™ Data Services 2 only)
Packagemx.rpc.remoting.mxml
Classpublic dynamic class RemoteObject
InheritanceRemoteObject Inheritance RemoteObject Inheritance AbstractService Inheritance Proxy Inheritance Object
ImplementsIMXMLObject, IMXMLSupport

The <mx:RemoteObject> tag gives you access to the methods of Java objects using Action Message Format (AMF) encoding.

MXML Syntaxexpanded Hide MXML Syntax

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

 <mx:RemoteObject
  Properties
  concurrency="multiple|single|last"
  destination="No default."
  id="No default."
  endpoint="No default."
  showBusyCursor="false|true"
  source="No default." (currently, Macromedia ColdFusion only)
  makeObjectsBindable="false|true"
  
  Events
  fault="No default."
  result="No default."  
 />
 

<mx:RemoteObject> can have multiple <mx:method> tags, which have the following tag attributes:

 <mx:method
  Properties
  concurrency="multiple|single|last"
  name="No default, required."
  makeObjectsBindable="false|true"
         
 Events
  fault="No default."
  result="No default."
 />
 

It then can have a single <mx:arguments> child tag which is an array of objects that is passed in order.

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.
RemoteObject
 Inheritedconstructor : Object
A reference to the class object or constructor function for a given object instance.
Object
 Inheriteddestination : String
The destination of the service.
AbstractService
  endpoint : String
This property allows the developer to quickly specify an endpoint for a RemoteObject destination without referring to a services configuration file at compile time or programmatically creating a ChannelSet.
RemoteObject
 InheritedmakeObjectsBindable : Boolean
When this value is true, anonymous objects returned are forced to bindable objects.
RemoteObject
 Inheritedoperations : Object
The Operations array is usually only set by the MXML compiler if you create a service using an MXML tag.
AbstractService
 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
  showBusyCursor : Boolean
If true, a busy cursor is displayed while a service is executing.
RemoteObject
 Inheritedsource : String
Lets you specify a source value on the client; not supported for destinations that use the JavaAdapter.
RemoteObject
Public Methods
 MethodDefined by
  
RemoteObject(destination:String = null)
Create a new RemoteObject.
RemoteObject
 Inherited
Disconnects the service's network connection and removes any pending request responders.
AbstractService
 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 RemoteObject is set up using a tag.
RemoteObject
 Inherited
Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter.
Object
 Inherited
Logs the user out of the destination.
AbstractService
 Inherited
Indicates whether the specified property exists and is enumerable.
Object
 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
If a remote object is managed by an external service, such a ColdFusion Component (CFC), a username and password can be set for the authentication mechanism of that remote service.
RemoteObject
 Inherited
Represents an instance of RemoteObject as a String, describing important properties such as the destination id and the set of channels assigned.
RemoteObject
 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 result event is dispatched when a service call successfully returns and isn't handled by the Operation itself.AbstractService
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:

endpointproperty 
endpoint:String  [read-write]

This property allows the developer to quickly specify an endpoint for a RemoteObject destination without referring to a services configuration file at compile time or programmatically creating a ChannelSet. It also overrides an existing ChannelSet if one has been set for the RemoteObject service.

If the endpoint url starts with "https" a SecureAMFChannel will be used, otherwise an AMFChannel will be used. Two special tokens, {server.name} and {server.port}, can be used in the endpoint url to specify that the channel should use the server name and port that was used to load the SWF.

Implementation
    public function get endpoint():String
    public function set endpoint(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
RemoteObject()constructor
public function RemoteObject(destination:String = null)

Create a new RemoteObject.

Parameters
destination:String (default = null) — the destination of the RemoteObject, 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 RemoteObject is set up using a tag. If you create the RemoteObject 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 RemoteObject lives
 
id:String — the id of this RemoteObject within the document
Examples
RemoteObjectExample
<?xml version="1.0"?>
<!-- Simple example to demonstrate the RemoteObject 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.
      The Java class mypackage.stockquote.MyTicker.class must be available on the 
      web application's classpath.

    <destination id="MyRemoteObjectDest">
        <properties>
            <source>mypackage.stockquote.MyTicker</source>
            <scope>application</scope>
        </properties>
    </destination>
-->

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

    <mx:RemoteObject id="RO" destination="MyRemoteObjectDest"
        fault="Alert.show(event.fault.faultstring), 'Error'">

        <mx:method name="GetQuote">
            <mx:arguments>
                <symbol>{stockSymbol.text}</symbol>
            </mx:arguments>
        </mx:method>
    </mx:RemoteObject>

    <mx:Panel title="RemoteObject 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="RO.GetQuote.send()"/>

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

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




Comments


mpeterson said on Jun 30, 2006 at 11:00 AM :
In the MXML example at the bottom of this page, "faultstring" should be "faultString".
- Mike Peterson
Adobe Flex documentation team
edward_apostol said on Mar 24, 2007 at 6:03 PM :
It would be useful to provide an example of connecting a Flex application to a remote object without the use of the destination attribute or configuring any config file.
smgilson said on Mar 26, 2007 at 1:10 PM :
Technically it's not easy out of the box.

You can make a feature request for this feature here: http://www.adobe.com/cfusion/mmform/index.cfm?name=wishform&product=20

Stephen Gilson
Flex Doc Team
brindy666 said on Nov 16, 2007 at 3:41 AM :
As a newbie I found it useful to know that the event objects are of type ResultEvent and FaultEvent respectively.
No screen name said on Jul 21, 2008 at 10:06 PM :
The description for the 'endpoint' property reads, "If the endpoint url starts with "https" a SecureAMFChannel will be used, otherwise an AMFChannel will be used"

However, if I set the endpoint to a relative path it always assumes http.

I believe this to be bug, if not would it be possible to have this object detect https when resolving the relative path?
mpeterson said on Jul 22, 2008 at 10:32 AM :
The ASDoc comment needs some additional text:
Relative URLs that retain the protocol of the loaded SWF file are not supported by this property. Iff you use a relative URL, the protocol will always be "http".
To get "https", the value you assign needs to start with "https".

- Mike Peterson
Flex doc team
No screen name said on Jul 22, 2008 at 4:56 PM :
Thank you for your quick response.

From what you're saying, if an swf is loaded through a secure channel (ie. via SSL), remoting data being sent to a gateway defined via a relative url will flow through an insecure channel instead of the original secure channel through which the swf itself was loaded.

So basically it's dangerous to use relative urls (at least for remoting) when the swf is loaded via SSL.
senthilckumar said on Jul 22, 2008 at 5:29 PM :
So this means a relative endpoint url will cause remoting data to be sent over an insecure channel even if the swf itself was loaded via a secure channel

I've got myself a work around for this by detecting the protocol using mx.core.Application.application.loaderInfo.url (on or after the applicationComplete event)

It would be less of a security issue if the endpoint property could do a similar sort of protocol resolution when it's set to a relative url

 

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/remoting/mxml/RemoteObject.html