Implementation of flex +.Net background with WebORB Remoting

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

Realization of flex background to communicate with the easiest way is to adopt httpServic mode, or webservice. But the two methods are text based transmission, low transmission efficiency,
Adopt RemoteObject mode, transmit the contents using binary code, AMF3 format, high efficiency, and can realize remote object invocation, the readability of the code, and the efficiency will be improved.

WebORB is a Adobe official recommended flex and.NET background RemoteObject solutions. At present, WebORB is completely free

The principle of WebORB is introduced:
1.    At Server end, WebORB uses the HTTPHANDLE mechanism of.NET, HttpHandle is a mechanism of ISAPI function in IIS is displayed in the.NET program, I understand it is actually a distribution mechanism of preconditioning mechanism. A similar function and HttpModule, such as the default when the website system was first visit is initialized later will not need to change the content of the HTTPMODULE mechanism using OnInit method overloading its implementation.

Such as the use of WebORB, need to add the following configuration in the web.config file:
      <add verb="*" path="weborb.aspx" type="Weborb.ORBHttpHandler"/>
      <add verb="*" path="codegen.aspx" type= "Weborb.Management.CodeGen.CodegeneratorHttpHandler"/>
This configuration represents all.Aspx HTTP request in IIS is assigned to the aspnet_wp.exe treatment, the name is weborb.aspx requests are handled by the Weborb.ORBHttpHandler class, so all the codegen.aspx page requests by Weborb.Management.CodeGen.CodegeneratorHttpHandler.

Inside the Weborb.ORBHttpHandler class, the first analysis of HTTP requests, according to the AMF3 binary format decoding flex, then according to the decoded information, through the reflection mechanism of.Net, the remote object invocation is converted into a.NET object, method and calling the client is specified, then generate the corresponding result set, and then encoded into the AMF3 format, the return to the customer.

2.    At client end, flex under compile time specified services-config.xml configuration, specify RemoteObect when calling the destination into the corresponding URL call, generates a corresponding HTTP request in the call, to be kind and method call into a HTTP request content according to the agreement.

Using the WEBORB method:
.NET version:.NET 2 VS2005 development environment
flex 3.0
eclipse flex builder
Download and install WebORB 1,
2 new engineering Flat
Copy WebORB project files in a directory (I was installed in the: C:\Inetpub\wwwroot\weborb30):
Copy weborb.config to the root directory
Copy diagnostics.aspx to the root directory
Weborb.dll copied to the App_WebReferences directory
3 references to flat project weborb.dll
4 modifications of the flat project's web.config file, add the following configuration:
      <add verb="*" path="weborb.aspx" type="Weborb.ORBHttpHandler"/>
      <add verb="*" path="codegen.aspx" type= "Weborb.Management.CodeGen.CodegeneratorHttpHandler"/>
The 5.copy WEB-INF directory of all files in the flat project directory, can be arbitrarily specified, but flex project must refer to this directory, I am here to copy: E:\wwwroot\FlexDataCenter\WEB-INF\flex
6 new CS file, add the following code:

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

/**//// <summary>
/// ComputeService abstract description
/// </summary>
public class ComputeService
    public ComputeService()
        // Add TODO: constructor logic here


    public int Compute(int arg1, int arg2)
        return arg1 + arg2;

The Compute method to implement a 2 parameters were calculated and the function.

7 in the eclipse in new flex engineering HelloNet.
8 modifications of the HelloNet project compiler attributes:
-locale en_US -services E:\wwwroot\FlexDataCenter\WEB-INF\flex\services-config.xml

Mainly is the need to develop the -services parameter, read path set services configuration file, so that the SWF file when using RemoteObject AMF channel mapping corresponding to the corresponding URL, this is very important!
A channel configure the default as follows:
<channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
            <endpoint uri="weborb.aspx" class="flex.messaging.endpoints.AMFEndpoint"/>
The configuration of the specified ID my-amf remote requests are mapped to the current site weborb.aspx, then by httphandle process weborb.aspx

9 modifications of the HelloNet project Build Path and debug run, path: E:\wwwroot\FlexDataCenter\Flex (this is the flat site directory)

Add the code in the Flex application file:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="" layout="horizontal"
            import mx.controls.Alert;
            import mx.collections.ArrayCollection;
                                    private function getComputerInfoHandler(event : ResultEvent) : void{
            private function getFaultHandler( event : FaultEvent) : void{
        <mx:Button label="test remote" click="compinfo.Compute(1,4);">
    <mx:RemoteObject id="compinfo" destination="GenericDestination"
                 showBusyCursor="true" >
           <mx:method name="Compute" result="getComputerInfoHandler(event)" fault="getFaultHandler(event);"/>


Note: the RemoteObject object's destination said to call back, are defined in the remoting-config.xml configuration file:
<destination id="GenericDestination">
By the end of.NET server
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Nelson at December 05, 2013 - 12:07 AM