Inter-process communication using AMF
One of the new features we added in the recent releases of WebORB for Java and .NET is the support for inter-process invocations via AMF. The feature lets you invoke Java, PHP or .NET code from any other process running in Java, PHP or .NET. It does not matter what process type is running on the other end, all combinations of the above are supported. For instance, you can have a .NET process invoking methods in Java object or EJB or PHP class. The only requirement is that the server-side class/service is running in a WebORB enabled application.
In this blog post I will describe how to put together a .NET application that makes an invocation of a remote class. For the simplicity sake, I will use a .NET class on the server-side, however, if you want to integrate with PHP or Java, the only difference will be in the endpoint URL.
A link to the full source code listing is available at the bottom of this blog post.
1. Create Visual Studio project
Make sure you have the latest version of WebORB for .NET installed. At the time of writing this blog post, it is 3.6.0.1. Create a Console Application project in Visual Studio. Add a reference to weborb.dll. The file is located in /Inetpub/wwwroot/weborb30/bin
2. Add invocation code
The API for AMF invocations is available in the Weborb.Client namespace. Make sure to import that namespace.
Create an instance of Weborb.Client.WeborbClient class. The constructor takes a URL to the server-side instance of WebORB. If you're using the default installation of the product, the URL is "http://localhost/weborb30/weborb.aspx".
Next, create an instance of the Weborb.Client.Responder class. The responder object contains references to the delegate functions - one when an invocation response is available, and the other to process errors. The generic parameter for the Responder class is the type of the return value you expect to get. The implementation supports the traditional WebORB type adaptation system. For instance, if the remote method returns an instance of System.Data.DataTable, you can specify T to be a collection of complex types. WebORB will automatically transform the data table into a collection of the given type as you will see below in the example.
Once a responder is ready, you can proceed to the invocation. The Invoke method on the WeborbClient class executes a remoting call. The method accepts the following arguments: name of the class containing the remote method, name of the method to invoke, array of arguments (or null if none) and the responder object. See below:

In the example above, the code calls the getCustomers method on the Weborb.Examples.DataBinding class. The method returns an instance of System.Data.DataTable. As you can see from the code above, it instructs WebORB to convert the return type to List, where every instance of CustomerVO will represent a row from the response.

With the implementation shown above, there will be only two 'columns' represented by the instances of the CustomerVO class. If more columns from the response are needed, just add additional properties to the class definition.
Finally, the code for the GotCustomers and GotError methods referenced in the Responder object above is shown below:

Before you run the code, it is recommended to open up the management console and verify the invocation of the backend method using the Test Drive feature. The console is available at the same URL you used in the code above: http://localhost/weborb30/weborb.aspx
Select the Management tab and navigate to weborb.dll > Weborb > Examples > Data Binding. Expand the node, select the getCustomers method and click Invoke on the right side of the interface. The console will send an invocation request and display method return value.











