Declaring a data service

You declare a data service in a data service tag. Flex applications access data services as unnamed or named services. You define an unnamed service entirely in the <mx:RemoteObject>, <mx:WebService>, or <mx:HTTPService> tag in an MXML application. To authenticate users, you must use a named service. A named service relies on explicit server configuration. For descriptions of data service tag properties, see Data service tag properties.

Unnamed services

You define an unnamed service entirely in an <mx:RemoteObject>, <mx:WebService>, or <mx:HTTPService> tag.

The following example shows an unnamed remote object service declaration. The source property specifies a fully qualified Java class name that is in the classpath.

<mx:RemoteObject id="MyService" source="credit.CreditCardAuth"/>

The following example shows an unnamed web service declaration. It specifies the service's identifier and WSDL document in the <mx:WebService> tag:

<mx:WebService id="MyService" wsdl="http://somewhere.com/my.wsdl"/>

You can use a relative or absolute URL in the wsdl property to access an unnamed web service. You can specify a relative URL in the following ways:

The following example shows an unnamed HTTP service declaration. The value of the url property can be a relative or absolute URL. A relative URL is relative to the context root of the web application and must begin with @ContextRoot().

<mx:HTTPService id="MyService" url="@ContextRoot()/directory/myfile.xml"/>

Named services

Named service declarations for remote object services use the named property instead of the source property. Named service declarations for web services and HTTP services use the serviceName property instead of the wsdl or url property.

The following example shows a named remote object service declaration:

<mx:RemoteObject id="employeeRO" named="SalaryRO"
   result="empList=event.result">
   <mx:method name="getList"/>
</mx:RemoteObject>

You define named services in <whitelist> tags in the flex-config.xml file. The <remote-objects>, <web-service-proxy>, and <http-service-proxy> tags in the flex-config.xml file each contain a <whitelist> tag that contains a <named> tag. For remote object services, the <named> tag contains child <object> tags for each named service. For web services and HTTP services, the <named> tag contains child <service> tags for each named service.

The following example sets up a remote object service named SalaryRO:

<remote-objects>
...
   <whitelist>
   ...
      <named>
         <object name="SalaryRO">
            <source>samples.explorer.SalaryManager</source>
            <type>stateful-class</type>
         </object>   
      </named>
   ...
   <whitelist>
...
</remote-objects>

For more information about whitelists for each type of data service, see Data service whitelist tags.


Version 1.5

 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flex/15/flex_docs_en/00000744.htm