Navigation:  Getting Started with WebORB >

Flash and WebORB

Previous pageReturn to chapter overviewNext page

The instructions below will guide you through the process of integrating a Flash client application with .NET backend using Flash Remoting.


The code used in this quick start guide is available in your WebORB distribution at:


Flash source:                         [WEBORB HOME]/examples/quickstart/flash
C# code/compiled assembly:         [WEBORB HOME]/examples/quickstart/server-side


The default location of [WEBORB HOME] is /Program Files/WebORB for .NET/4.0/


.NET Service

The server side code for this quick start guide can be found at the following path in your WebORB installation: [WEBORB HOME]\examples\quickstart\server-side. The directory also includes a compiled assembly (quickstart.dll). You can either compile the code yourself, or use quickstart.dll. To expose the server-side class as a remoting service through WebORB, the assembly must be deployed to the /bin folder of your WebORB installation. Once you deploy the assembly, you can verify that it is recognized by WebORB by opening the WebORB Management Console and selecting the Services tab. The assembly will show up in the ".NET Assemblies" node in service browser.


The source code for the server-side class is below:

using System;
using System.Web;
using Weborb.Util;
namespace weborb.examples.quickstart
 public class ComputerInfoService
   public ComputerInfo getComputerInfo( String requestId )
     ComputerInfo computerInfo = new ComputerInfo();          
     System.Web.HttpRequest request = ThreadContext.currentRequest();
     computerInfo.serverName = request.ServerVariables[ "SERVER_SOFTWARE" ];
     computerInfo.clrVersion = Environment.Version.ToString();
     computerInfo.clrVendor = "Microsoft";
     computerInfo.os = Environment.OSVersion.Platform.ToString();
     computerInfo.osVersion = Environment.OSVersion.Version.ToString();
     computerInfo.requestId = requestId;
     return computerInfo;
 public class ComputerInfo
   public string serverName;
   public string clrVersion;
   public string clrVendor;
   public string os;
   public string osVersion;
   public string requestId;


Flash Client

Open Flash source file from [WEBORB HOME]/examples/quickstart/flash/quickstart.fla. The code uses the NetConnection API to invoke a method on a .NET object. To connect to WebORB, Flash client must use a remoting gateway URL. This is the URL where remoting requests are sent to. The sample code contains two options for connecting to WebORB. If the compiled client application (SWF) is loaded from the same server where WebORB is running, it can connect using a relative URL (weborb.aspx) or an absolute URL (http://localhost/weborb4/weborb.aspx). See the code below:

var nc:NetConnection = new NetConnection();
// if running this client from file system, put full WebORB URL into connect()
// if you uncomment the line below, make sure to comment out conect( "weborb.aspx" )
// nc.connect( "http://localhost/weborb4/weborb.aspx" );
// if the client is loaded from the webserver where WebORB is running, use relative URL:
nc.connect( "weborb.aspx" );
var responder:Responder = new Responder( computerInfoRetrieved, callFailed ); "weborb.examples.quickstart.ComputerInfoService.getComputerInfo", responder, reqID++ );


The "nc.connect( "weborb.aspx")" line connects to a relative URL. As long as the Flash application is loaded from the same virtual directory where WebORB is installed, it will be able to connect and communicate with WebORB.


The line where a Responder object is created is important as it creates a special (Responder) object which references two other functions. One (computerInfoRetrieved) is invoked when Flash client receives a response from the remote method invocation. The callFailed function is invoked if the server reports an error or the remote invocation results in an exception. Finally the line sends a remoting invocation request to the server. The call has the following arguments:


"weborb.examples.quickstart.ComputerInfoService.getComputerInfo" - uniquely identifies a remote method to be invoked. The method name is the last part (getComputerInfo). The name of the class comes before the method name (ComputerInfoService). The other part is the namespace of the class (weborb.examples.quickstart).
responder - an instance of the Responder class which references result and failure callback functions
reqID++ - argument for a remote method invocation. If the remote method has more than one argument, values can be included into separated by comma (for example, "namespace.class.methodname", responder, arg1, arg2, arg3 )).


Deploying and Running the Flash Client

To deploy the Flash client for the example reviewed in this guide, publish the Flash application and copy SWF and HTML files to the root of the weborb4 virtual directory (the default location is /Program Files/WebORB for .NET/4.0/). You can run the Flash client by opening the following URL: http://localhost/weborb4/quickstart.html


Alternatively, you can modify the code of the client application to connect to WebORB using the absolute URL (see the comments in the getComputeInfo() function in the ActionScript code of the FLA). Once changed, you can run the client application directly from Flash or by opening the SFW/HTML from the file system.