Monday, April 21, 2008

A First Look at BlazeDS: RPC Mechanisms

Many of us were excited to hear about Adobe's releasing of BlazeDS in late 2007. However, there seemed to be a relative lack of documentation on how to use BlazeDS as compared to other Flex approaches. However, since that announcement, there have been several good resources explaining BlazeDS. These include Andrew Powell's blog entry BlazeDS in Plain English, Wade Arnold's blog entry BlazeDS: Worth Figuring Out! Hello World Example, Christophe Coenraets's article BlazeDS 30-Minute Test Drive, BlazeDS Developer's Guide, BlazeDS Public APIs, BlazeDS Features list, BlazeDS: Remoting != Messaging and the BlazeDS and LCDS Feature Difference table.

HTTPService: With and Without BlazeDS

BlazeDS supports HTTPService. This can be a little confusing at first because HTTPService has been available in the free Flex SDK since Flex 2 and before BlazeDS was made available. In fact, it is the same HTTPService in both cases. Without BlazeDS, a Flex developer is limited to using HTTPService with its useProxy attribute set to false and the connection is made directly to the HTTP service specified by the url attribute.

So, why is it useful to be able to set HTTPService.useProxy=true to take advantage of BlazeDS's proxy server support for HTTPService? The advantage is that BlazeDS's support for the Flex proxy server allows for use of HTTP methods other than POST and GET (including DELETE and TRACE). This is more REST-friendly and is described in the Flex 3 Language Reference documentation for HTTPService.

Another advantage of using BlazeDS in conjunction with HTTPService is that doing so removes the need to use a crossdomain.xml file when accessing a remote server from a Flex application. Besides removing the need for a crossdomain.xml file, the use of BlazeDS server proxy also enables more granular control over access of a server-side service. This means that useful additions like service authentication and service access logging can be performed.

WebService: With and Without BlazeDS

Like HTTPService, the Flex WebService is supported both with and without BlazeDS. The differences between using WebService without BlazeDS as compared to with BlazeDS are similar to those for HTTPService. Instead of the url attribute (used by HTTPService), a WebService used without BlazeDS will use the value of the wsdl attribute as the location of the server-side SOAP-based web service to invoke and, as with HTTPService, the useProxy attribute must be set to false when BlazeDS (or other Flex server implementation) is not used.

As with HTTPService, there are advantages to using WebService in conjunction with a BlazeDS-provided Flex server. These advantages are strikingly similar to those for HTTPService with BlazeDS: no need for a crossdomain.xml when remotely accessing a web service on a remote machine and greater ability to log access or perform authentication checks on potential web service access.

RemoteObject: Only Available with BlazeDS

The previously mentioned two RPC approaches (HTTPService and WebService) can be used with or without BlazeDS. BlazeDS supports a third RPC mechanism, RemoteObject, that is not available in standard Flex without BlazeDS (or other Flex server proxy product).

Besides being only available with BlazeDS, another difference with RemoteObject (as compared to HTTPService and WebService) is the encoding used with RemoteObject. While HTTPService and WebService both make use of XML/text over HTTP, RemoteObject uses Action Message Format (AMF) encoding. Also, RemoteObject allows Flex developers to write ActionScript code as if they were accessing server-side Java classes directly rather than handling XML as is often the case with HTTPService and WebService.

The three RPC mechanisms supported by BlazeDS are highly useful and each has its own advantages. I hope to devote some future blog entries to more in-depth details on each of these three RPC mechanisms and to demonstrate them with code examples. I also plan to include future blog entries on the Flex-to-server communication support offered by BlazeDS outside of the RPC mechanisms (Messaging mechanisms).

2 comments:

thiagu said...

Hi,

can you pls help me out.
I have a tomcat server with blazeds
trying to communicate with a webservice
located on a weblogic server

In my MXML client I have the

useProxy="true" and
destination="ultMLT"

In my proxy-config.xml under

WEB-INF/flex

I have the following setup

destination id="ultMLT"
properties
remote-username g9uant remote-username remote-password Arvnd_14 remote-password
wsdl http://localhost:7001/WebServices/UltimateLookThruService?WSDL wsdl
soap http://localhost:7001/WebServices/UltimateLookThruService soap properties
adapter ref="soap-proxy"
destination


The communication happens ..
But on the weblogic side the logs show that it failed as it was approached with user id as "anonymous"

I have set the "remote-username" and "remote-password" as suggested in the docs

What am I missing here.

Does this not work in Blazeds .


Any help in this matter will be greatly appreciated.

Thanks
Thiagu
(alagesan thiagarajan)

shaik subhani said...

How to make a flex application to use specific proxy while making HTTP request ??

How to make a flex application to use specific/custom proxy while making HTTP request ?? (without using LCDS/Blaze DS) .Our application is only windowed application. If any one finds a solution for this ? please reply to this post