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

Thursday, July 13, 2006

ARP PizzaService ported to .NET

Beta 5 release of WebORB includes a copy of the ARP PizzaService example ported to .NET. It was a fun exercise to see how long it would take to get it running in WebORB. The process took about 40 minutes and now we have an awesome example demonstrating the use of mx:RemoteObject in the ARP framework invoking C# methods through WebORB.

There is a full blown article describing the ported example at:
http://www.themidnightcoders.com/articles/dotnetpizzaservice.htm

You can see and run the example if you download WebORB 2.1 Beta 5 for .NET.

Huge thanks go to Aral Balkan for creating the original example.

WebORB 2.1 Beta 5 for .NET is released

The new beta release delivers an important product update enabling integration with the final release of Flex 2.0. Flex clients created with the production version of Flex Builder or Flex SDK can bind and invoke .NET objects hosted in a WebORB server version 2.1 Beta 5. There were several bug fixes we included into the release including:

- support for the 'scope' element used to identify service activation mode in remoting-config.xml and data-management-config.xml
- fixed a bug with nested static circular references in complex types (type A containing a static property of type A)

The goal for the next Beta release is to provide more compliance with the Data Management Services functionality - support for complex associations, transactions and throttling policies.

Wednesday, July 05, 2006

Flash Remoting 101: Setup and First Invoke

This post continues the "Flash Remoting 101" mini-tutorial series. Previous post describing what Flash Remoting is is available here. To get started you will need to install the following products:
Once everything is installed, start Flash 8 and create a new Flash document. Open Actions panel and select the first frame in the timeline as shown in the image below:


Paste the following code into the Actions panel:

import mx.remoting.Service;
import mx.remoting.PendingCall;
import mx.rpc.RelayResponder;
import mx.rpc.ResultEvent;
import mx.rpc.FaultEvent;

// if using WebORB for Java, the URL should be:
// http://localhost:8080/weborb
var webORBURL = "http://localhost/weborb/weborb.aspx";

var serviceProxy = new Service( webORBURL, null,
"weborb.tests.PrimitiveTest",
null, null);

var callObj:PendingCall = serviceProxy.echoInt( 21 );
callObj.responder = new RelayResponder( this, "echoIntResponse", "echoIntFailure" );

function echoIntResponse( resultEventObj:ResultEvent )
{
trace( "server returned - " + resultEventObj.result );
}

function echoIntFailure( fault:FaultEvent )
{
trace( "received error - " + fault.fault );
}

The code above creates a proxy for a server-side object of the weborb.tests.PrimitiveTest class. The code then invokes the echoInt() method and passes a hardcoded argument (21). The RelayResponder object specifies two methods: one receives a result from the successful method invocation and the other to be called if an error occurs.

On the server side, create a class with the following code:

Java:
package weborb.tests;

public class PrimitiveTest
{
public int echoInt( int i )
{
return i;
}
}


.NET (C#)
namespace weborb.tests
{
public class PrimitiveTest
{
public int echoInt( int i )
{
return i;
}
}
}


Compile the code and deploy it into WebORB. If you are running Java, PrimitiveTest.class must be copied into [WEBORB HOME]\webapp\WEB-INF\classes\weborb\testsTo run WebORB for Java, open a command prompt window, change directory to [WEBORB HOME] and run the following command: "java -jar weborb.jar".

With .NET, you can compile the class in a separate "class library" project and copy the project output assembly into \Inetpub\wwwroot\weborb\bin. The class will be automatically deployed and exposed to Flash client.

Now the server side is ready to accept a Flash Remoting method invocation. To run the client return to Flash 8 and press Ctrl + Enter. Flash runs the movie and invokes the method on the server object.

If you would like to bypass server-side configuration and run the example against a WebORB installation on our server, use the following as the WebORB URL:
"http://www.themidnightcoders.com/examples/weborb.aspx"

Saturday, July 01, 2006

Flash Remotring 101: Getting started

This is the first post in a series of mini tutorials dedicated to the subject of Flash Remoting and WebORB. The series starts from the very basics of both technologies and will delve into more advanced features over time.

A few basic FAQs to get started:

Q: What is Flash Remoting?
A: Flash Remoting is a technology enabling connectivity between a Flash client application and a server-side component.

Q: How does a Flash client connect to a server-side object?
A: The technology consists of two parts: 1) client-side ActionScript library and 2) server-side technology responsible for handling object invocation. Both parts must understand a binary protocol called AMF - Action Message Format. The client side library is called 'Flash Remoting Components'. There are two available implementations: one for ActionScript version 1.0 and the other is for AS2.0. The Flash Remoting Components are available at no charge from the Adobe's site (download remoting components here). There are several server-side technology implementations available for many platforms and development environments. WebORB is one of them, it provides a fully compatible implementation of AMF and thus can handle object invocation requests received from Flash clients.

Q: How does Flash client invoke a method on a server-side object/service?
A: Flash Remoting Components provide object binding API. Every object must be identified with either an ID or fully qualified class/type name or WSDL URL. Additionally a Flash Remoting-enabled server (WebORB or any other server) must expose a 'gateway URL'. Flash client connects to the server using gateway URL and then uses object ID, class/type name, or WSDL URL to connect to a particular object/service. Once connected, Flash Remoting Components generate a client-side proxy for a remote object. Flash Remoting Components relay all method invocation on the proxy object to the server-side.

Q: What type of server-side components does WebORB support?
A: WebORB is currently available for the Microsoft .NET and Java environments. We're also working on two additional editions for PHP and Ruby on Rails. WebORB for .NET can handle invocations of any .NET object (regardless of what language it is written) and XML Web Services. The Java edition provides connectivity to Java objects, EJBs and XML Web Services.

Q: How would WebORB work with my application?
A: WebORB for .NET is available as a .NET assembly (weborb.dll). To expose classes from your application to Flash clients, you can simply copy weborb.dll into the /bin folder and register it as an HTTP Handler. WebORB for Java is available as a JAR, WAR or EAR file. It can be deployed into any Java servlet container or J2EE server.

Q: Is there anything special I need to do to expose my objects to Flash?
A: One of our architectural goals is non-intrusiveness. As a result, WebORB does not require any changes to the classes exposed to Flash. It will make the best effort to convert objects received from Flash to adapt them to local types. Similarly WebORB will make sure that a return type is properly serialized to Flash so it is understood in the client (ActionScript) environment.

The diagram below provides a high level overview of how all the parts mentioned above fit together.