Spring and SOAP
Since JTeam is such a hip Java shop, and since one of the founders is co-writing the book on the subject, we try to use the Spring framework whenever we can.
For an in-house project, I wanted to expose a Spring-managed business interface by SOAP to a Windows Forms .NET client. Unfortunately, there is no SOAP support in Spring yet, so I decided to write it myself. How hard can it be, right?
Instead of delving into code, I started with the exterior: the way I wanted the SOAP support to be defined in my beans definitions. I wanted it to be similar to the standard remoting export services found in subpackages of org.springframework.remoting (like the HessianServiceExporter). Thus, I wanted it to look like this:
jteam.managers.ServiceManager
Happily, I started to code the SoapServiceExporter. I did not have the urge to write my own SOAP server, so I needed a Java-based SOAP implementation to which I could relay the messages. I started with Axis, since that seems to be standard in Java land. All seemed well when I read the Architecture Guide: it seemed pretty pluggable. However, when I inspected the source of AxisServlet, I saw that the doPost method - which is most important - was about two hundred lines of message-handling logic. No way that I was going to copy-paste that into my SoapServiceExporter to achieve the same results.
Next up was ActiveSOAP, which has a much lighter feel to it. It seems to be pretty usable for my demands, except for the fact that it only seems to export interface methods which have one parameter, which you can see here and here. I wonder why that is.
So that’s where I am right now. In some future post, I will conclude this tale…
Update: Since I originally wrote this post, my thoughts on Web Services have changed considerably. Read this series of articles to see how.
February 3rd, 2005 at 5:17
You can use Mule to expose Spring beans as web services and invoke web services from your beans. Mule isn’t a soap provider but uses a common interface for invoking soap as well as jms, tcp, http, pop3, smtp, etc. There is an example of how to expose Spring beans a web services here.
Mule currently supports Axis (no servlet engine required) and Glue and will support StAX-based providers like ActiveSoap and XFire shortly. Mule uses the Spring ApplicationContext event mechanism so it’s almost transparent to your application. There is a beginners guide to using Mule with spring here.
Cheers,
Ross
February 11th, 2005 at 0:50
Not sure if you particularly need RPC SOAP support, but using Document centric SOAP it is a piece of cake to implement just with a servlet and XmlBeans.
February 11th, 2005 at 2:00
Copy and Paste? Why would anyone want to copy Axis source code someplace else? Why don’t you use it directly?
February 11th, 2005 at 10:02
Ross,
Mule certain looks interesting, and it’s Spring support looks good too.
However, if I want to use it, I have to implement a Mule interface (either
MuleEventListenerorMuleSubscriptionEventListener). I don’t think that exposing a business interface via SOAP should require me to change my implementations: it should all be taken care of by the framework, just like the otherServiceExporters in Spring.February 11th, 2005 at 10:32
Dmitri,
XMLBeans are cool, but what I said about Mule interfaces also applies here: I don’t think it is neccesary to change my existing business interfaces and value objects just to expose them over SOAP.
February 11th, 2005 at 10:39
I don’t want to copy and paste the Axis code, but I don’t want to use the
AxisServletin my webapp either. What I do want is to use the Axis framework within my Spring Controller, but since there is so much logic in theAxisServlet, I cannot do so.August 26th, 2005 at 23:18
That is so funny. It is like saying: I do not want to change anything in my car, but it should sail, fly, and finish race first!