All posts by Alexander Ananiev

Are Web Services Suitable for SOA?

SOA may mean different things to different people (to me, SOA is just an
architectural style), but one thing is certain – SOA is being touted as the next
generation enterprise integration technology and architecture. And yes, SOA is
not all about Web services; however, Web services (SOAP and WSDL specifically)
are immediately brought into conversation when SOA is mentioned.

But do Web services today provide necessary enterprise-level capabilities?

Take transaction support. Ideally, we should be able to wrap any access to a
remote resource in a transaction since remote resources are prone to failing. In
J2EE , this is certainly supported for JMS , JDBC and RMI . Yes, two-phase
commit comes at a price, but it‘s nice to have it available when it‘s needed.
Now, SOA is all about remote calls (synchronous or asynchronous, does not matter).
So where is the transaction support? Well, there is WS-AtomicTransaction
specification that in theory should provide it. But where are the products that
support it today? Also, this specification is not currently part of any WS-I
profile, so interoperability is a big question.

WS-ReliableMessaging is in the similar situation, and so the rule of thumb today
is that Web services should conform to WS-I basic profile, which does not
include any of the advanced specifications.

In theory, one could use SOAP over JMS supported by many J2EE vendors today
which immediately makes SOA implementation more robust. But this approach is
hardly interoperable with non-Java technologies and what is it really buying for
J2EE applications? JMS is already an abstraction of the messaging middleware, so
why do we need another abstraction on the top of it?

I concede that describing JMS destinations using WSDL might be useful for some
environments, but in many cases it is simply overkill (if you must use BPEL ,
use the BPELJ variant which directly supports JMS ).

Using JAX-RPC or WSIF to communicate with JMS does not sound like a good idea
either. These APIs are not JMS -aware, so, for example, how do I get/set
messageID or correlationID?

I do realize that developing true enterprise-level integration technologies
takes time, and so perhaps in a couple years most Web services products will
provide WS-Transaction and WS-ReliableMessaging support out of the box. But are
Web services really ready to take on the enterprise today?

Hurdles with Document-Style Web Service

Lat week I spent some time prototyping a simple document-style web service. Basically, I wanted to figure out how to pass an XML document with several nested repeating groups to a web service. Apache Axis was the obvious choice for a SOAP engine-I did not want to install anything heavy.

I totally expected it to be a half an hour deal at most — after all, SOAP is already XML, so wrapping my XML message in SOAP envelope should not be a big deal, right?

In reality though, I immediately ran into issues. My first approach was to try to pass an object graph (a la order with line items). Turned out, Axis does not know how to serialize objects in case of “document literal“ service; serialization only works for “soap encoded“. I can understand that-since this is custom XML, rules for serialization are not defined. Although it could‘ve generated some default names based on reflection (I wish we could use annotations for that, but that would have to wait until JAXB 2.0).

Then I tried passing XML as a string (still with “document literal“ in wsdl). Axis had some problems recognizing the name of the operation (basically, the name of the parameter had to match the name of the operation) and then it escaped the XML string (using entities such as “& lt;“). This was not acceptable-I could not count on all clients uniformly escaping their XML before calling the service

So I ended up using DOM and special “message“ style web service that Axis supports-in this case the signature of the service would be “public Document process( Document message )”. This works fine, although I still had to mess with SOAPElement on the client and I could not pass the XML string directly. I actually ended up writing a simple utility class to convert XML string to SOAPElement. Unfortunately, this approach is not portable-WebSphere, for instance, does not support it. So much for JAX-RPC spec support.

This article explains how it should work by the spec but it is obvious that support for at least this part of the spec varies among different implementations.

Morale of the story? “document literal“ web service style is touted everywhere as the “right” way to implement the service but its support leaves a lot to be desired.