| Flex 2 Developer's Guide > Data Access and Interconnectivity > Using RPC Components > Declaring an RPC component > Using an RPC component with a server-side destination | |||
An RPC component's destination property references a Flex Data Services destination configured in the services-config.xml file or a file that it includes by reference. A destination specifies the RPC service class or URL, the transport channel to use, the adapter with which to access the RPC service, and security settings. For more information about configuring destinations, see Configuring RPC Services.
To declare a connection to a destination in an MXML tag, you set an id property and a destination property in one of the three RPC service tags. The id property is required for calling the services and handling service results.
The following examples show simple RemoteObject, HTTPService, and WebService component declarations in MXML tags:
<?xml version="1.0"?>
<!-- fds\rpc\RPCServerMXML.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<!-- Declare a RemoteObject component. -->
<mx:RemoteObject
id="employeeRO"
destination="SalaryManager"
useProxy="true"/>
<!-- Declare an HTTPService component. -->
<mx:HTTPService
id="employeeHTTP"
destination="SalaryManager"
useProxy="true"/>
<!-- Declare a WebService component. -->
<mx:WebService
id="employeeWS"
destination="SalaryManager"
useProxy="true"/>
</mx:Application>
The following examples show simple RemoteObject, HTTPService, and WebService component declarations in ActionScript. You would place the code in these examples inside ActionScript methods:
<?xml version="1.0"?>
<!-- fds\rpc\RPCNoServerAS.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
// Import required packages.
import mx.rpc.remoting.RemoteObject;
import mx.rpc.http.HTTPService;
import mx.rpc.soap.WebService;
private var employeeRO:RemoteObject;
private var employeeHTTP:HTTPService;
private var employeeWS:WebService;
public function declareServices():void{
// Create a RemoteObject component.
employeeRO = new RemoteObject();
employeeRO.destination = "SalaryManager";
// Create an HTTPService component.
employeeHTTP = new HTTPService();
employeeHTTP.destination = "SalaryManager";
// Create a WebService component.
employeeWS = new WebService();
employeeWS.destination = "SalaryManager";
}
]]>
</mx:Script>
</mx:Application>
Flex 2.01