Blog to discuss Midnight Coders products features, ideas and trends in development of Rich Internet Applications

Monday, December 08, 2008

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. 

Full source code listing with the Visual Studio project files

Thursday, December 04, 2008

WebORB 3.6 for .NET is available

If you're working with the .NET version of our product, we have some news for you. There is a new release with some important features as well as bug fixes. See below for details:
  • Support for Silverlight client - Includes client-side component with remoting APIs, code generator integrated into the management console as well as a command line code generation utility. Silverlight integration makes it super simple to invoke methods on remote objects as well as SOAP/REST web services. Btw, Silverlight integration works across all WebORB implementations thus you can connect Silverlight with .NET, Java, PHP and soon ColdFusion components.

  • Support for server-to-server AMF invocations - Previous release made it possible to do server-to-server (or process-to-process if you will) invocations via RTMP. With 3.6 you can accomplish the same using AMF over HTTP. This should allow cross-platform integration where .NET can invoke Java or native .NET apps can call each other using simple and intuitive API without all the complexities associated with cross process integration.

  • WebORB Visual Studio templates - Many of you asked for it and we listened. The product installer registers Visual Studio templates with your installation of VisualStudio 2005 and 2008 (whichever you have installed). The templates are available for C# and Visual Basic. There are two types of templates: one to create WebORB-enabled website projects and the other is for WebORB-enables class libraries. We put together a few screencasts demonstrating the templates in action:
    Using WebORB Visual Studio templates - Part 1
    Using WebORB Visual Studio templates - Part 2

  • Custom MSMQ queue factories support - When using Producer/Consumer APIs with the messaging destinations connected with MSMQ, you may have a scenario when you need to construct instances of the queue in your own code. WebORB now supports custom queue factories to support this use-case. See the comments in WEB-INF/flex/messaging-config.xml (the <queuefactory> element)

  • Class mappings between abstract generic collections and concrete implementations - Suppose you have a remoting method that declares an abstract generic argument:

    public void processOrders( IList<Order> orders )
    {
    }

    Since the argument is an abstract type, WebORB would need to know what concrete generic implementation should be used for that IList. The new release provides a way to establish mappings between abstract generic types and a concrete implementation. See <abstractclassmappings> section in weborb.config for more details.

  • Bug fixes:
    - Fixed a bug with reference serialization. The error was resulted in a message "Error #2006: The supplied index is out of bounds"
    - Fixed a bug with AJAX remoting and Firefox 3
    - Fixed a bug with serialization of very large data sets
    - Fixed a bug with passing credentials in AJAX invocations
As always, we love to get feedback. Please drop us a line and let us know what we could do better or differently.

We have a new website - come check it out!

The stack of topics I want/need to blog about is experiencing a major overflow, so I'll start in the chronological order.

If you have not been to our website lately, I recommend you check it out: http://www.themidnightcoders.com

We have completely redesigned the site and I am very pleased with the new design. Unlike all previous versions of our site, we now have a CMS system. It is not perfect, but certainly a major step forward from where we were. The new site should make it easier to find information about the products and services we provide. We're also incorporating a commenting system for the pages with technical information (like technotes, articles and screencasts). If you see something we might have missed or should improve, we'd love to hear from you.

Also, just for fun I used the Web Archive to see what the site looked like in the past. Below are the thumbnails of the home page versions going back to 2003 when I launched the company and created the very first version of the site:

Version 1 (2003):


Version 2 (2004):

Version 3(2005):


Version 4(2007):


Version 5 (current)