Flex and. Net interoperability (7): Understand fluorinefx environment configuration (remote object, gateway, channel, destination)

Source: Internet
Author: User
The Remote Object Access in flex, that is, the process in which the server provides a remote service object, and the flex client calls the remote object through the corresponding access technology.

In this seriesArticleThe WebService access method described in the previous articles is a remote object method, but it is a remote access based on Web Service (webservie, it is not a remote access based on a remote object. It is troublesome to directly implement object-based Remote Access, and fluorinefx specifically provides this function for us to develop the remoting object service through the core library of fluorinefx, how is it implemented? Fluorinefx requires that the [remotingservice] Mark be provided for remote objects to provide remote object services. Let's take a look at the detailed definitions of remotingserviceattribute below:

1 [Attributeusage (attributetargets. Class, allowmultiple =   False )]
2 Public   Sealed   Class Remotingserviceattribute: attribute
3 {
4 Public Remotingserviceattribute ();
5 Public Remotingserviceattribute ( String Servicename );
6 }

From the example in the previous articleCodeWe can see that the remote object service class of a sample is defined using. Net (C #), and the [remotingservice] is specified for it. The details are as follows:

1 [Remotingservice ( " Fluorine Sample Service " )]
2 Public   Class Sample
3 {
4 Public Sample ()
5 {
6 }
7
8 Public   String Echo ( String Text)
9 {
10 Return   " Gateway ECHO: "   + Text;
11 }
12 }

 

In the previous article, the fluorinefx and. NET development environment has seen a remote object example of flex client calling fluorinefx. Let's take a look at this example:

1 < MX: remoteobject ID = " Service " Destination = " Fluorine "
2 Source = " Flexdotnet. servicelibrary. Sample " >
3 < MX: Method Name = " Echo " Result = " Onresult (Event) " >
4 </ MX: Method >
5 </ MX: remoteobject >

1 < MX: script >
2 <! [CDATA [
3 Import MX. rpc. Events. resultevent;
4 Internal Function onclick (): Void
5 {
6 Service. Echo (txtinput. Text );
7 }
8
9 Internal Function onresult (EVT: resultevent ): Void
10 {
11 Txtresult. Text = EVT. Result. tostring ();
12 }
13 ] >
14 </ MX: script >

 

For example, remote object access can be achieved through the flex non-visual component <mx: remoteobject> for remote object connection. The source attribute specifies a remote object in the format of a fully qualified name (namespace + class name ). The destination attribute is very important, which determines whether the flex client can correctly access the remote object. The configuration is as follows:

1 < Destination ID = " Fluorine " >
2 < Properties >
3 < Source > * </ Source >
4 </ Properties >
5 </ Destination >

 

In the <mx: remoteobject> component, use the <mx: mothod> component to configure remote objects. For details, see the previous section. The core of achieving remote object access is the Object Adapter and connection channel:

1 <? XML version = " 1.0 " Encoding = " UTF-8 " ?>
2 < Service ID = " Remoting-Service "
3 Class = " Flex. messaging. Services. remotingservice "
4 Messagetypes = " Flex. messaging. Messages. remotingmessage " >
5 < Adapters >
6 < Adapter - Definition ID = " DOTNET "   Class = " Fluorinefx. remoting. remotingadapter "   Default = " True " />
7 </ Adapters >
8
9 < Default - Channels >
10 < Channel Ref = " My-AMF " />
11 </ Default - Channels >
12
13 < Destination ID = " Fluorine " >
14 < Properties >
15 < Source > * </ Source >
16 </ Properties >
17 </ Destination >
18 </ Service >

 

In actual development, we can customize communication channels. By default, fluorinefx provides us with the default connection channel:

1 < Channels >
2 < Channel-Definition ID = "My-AMF" Class = "MX. messaging. channels. amfchannel" >
3 < Endpoint Uri = "Http: // {server. Name }:{ server. Port}/{context. Root}/gateway. aspx" Class = "Flex. messaging. endpoints. amfendpoint" />
4 < Properties >
5 <! -- <Legacy-collection> true </legacy-collection> -->
6 </ Properties >
7 </ Channel-Definition >
8 </ Channels > Tag

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.