Thursday, August 23, 2007

Spring Web Services, Finally!

Spring Web Services seems to be the technology I have been looking for recently. I am not a Spring bigot (too XML oriented), but here the Spring folks have something right.

I used to work with Web Services the simple way: create a java class (or EJB), expose it as Web Service through Axis or RAD, generating the WSDL in the process. And then a client would just be the reverse, take the WSDL, use a tool (Axis or RAD) that creates client Java classes from it automatically. Simple, easy.

But this process starts to fail if you have
  1. several very similar WSDL: you want reuse instead of copy.
  2. other means of communicating XML represented by the XML schema embedded in the WSDL, for example via direct MQ use.
In those cases, the contract first approach is particularly interesting. However most tools, if they allow contract first approach, they don't give you enough access on the message itself, and you can do 1), but not 2). I always found a bit silly that Axis or RAD had to have the logic to marshall/unmarshall java objects, but they did not give any explicit API access to do it, or to replace it with a standard way (JAXB 2 for example).

I found 2 techs that can help:
  • SDOs (Service Data Objects): from my short experience, I find it a bit too verbose, and not yet fully mature, as you depend on libraries external to SDO ones for it to work in the case of web services. It can work, and if you use IBM products, it could be a good way to write Web Services Providers/Clients.
  • Spring Web Services: I have not tried it yet, but it seems to solve exactly the kind of problems I described earlier. And you can plug-in any marshalling/unmarshalling framework you want :).
There are so many libraries to do web services, and different approaches, that an initiative like Spring Web Services is more than welcome!

1 comment :

  1. You can use any marshalling technology with Axis. I used JAXB with Axis 1.x quite a while ago. The "trick" is to tell Axis to not process the XML document (document type=XML iirc), and it will give it to you as is. Details are sketchy (that was a while ago), but it is doable!

    ReplyDelete