Web Services at 10000 Feet
At Polar Rose we’ve been using XML-RPC for our (internal) web services. Simply because it is such a simple protocol and fairly well supported in all (scripting) languages. I’ve really been avoiding the WS-* Deathstar for a while now but I finally bit the bullet and started using SOAP again.
Last night when I was flying back home from our Warsaw office I spend some time in the air to setup a Spring application to expose a simple service through XFire. The XFire documentation is a bit scarce but I had things up and running pretty quickly after the fasten-your-seatbelts sign went off. In the end I just needed a minimal Spring configuration and the right stuff in web.xml to get it all going. The Java side of things is just an interface with a @WebService annotation and a simple implementation.
@WebService
public interface HelloService {
String sayHello(String name);
}
public public class HelloServiceImpl implements HelloService {
public String sayHello(String name) {
return "Hallo, " + name + "!";
}
}
I also have some methods that take or return some more complex data structures and that all just works fine.
The client side was a little more trickier. I wanted to do a simple Ruby client but I could not get SOAP::WSDL going. That must be one of the worst documented Ruby modules. At least in the 1.8.2 that comes with OS X. Fortunately I also had a recent Python install on my MacBook, including the SOAPPy module. That was really easy to get going:
from SOAPpy import WSDL
service = WSDL.Proxy('http://localhost:8080?HelloService?WSDL')
print service.sayHello('Stefan')
I keep telling myself that I should focus on one scripting language next to my regular Java work. Maybe this is a good moment to switch to Python
I’ll put my sample project online later today.
Modified
