Simon Fell > Its just code > WS-Programming Models

Sunday, May 7, 2006

I've ranted about this before, the next generation of WS stacks bring new programming models with them, and I can't for the life of me work out why someone thinks they're better than what's before. I keep hearing that's its a purer mapping to the message declarations in the WSDL. In which case, exactly what the fuck is the portType for in WSDL, in the brave new world it seems to carry zero semantic scope, other than mapping messages to URLs. Part of me is laughing so hard, the shinny new programming model is exactly what the PocketSOAP WSDL wizard has been generating for the last 4 years!, It works, but its painful to use, so much tedious boiler plate code, now new stacks like Axis2 and WCF (nee Indigo) and declare this model the best thing since sliced bread, I don't get it, is purity of model really worth all the extra boiler plate code you're asking everyone to code up ?, e.g. here's some Axis 1.x code to create a stub and call an operation that take 2 elements.

Soap svc = new SforceService().getSoap();
LoginResult lr = svc.login(username, password);

Here's the axis2 equivalent (using the xmlbeans databinding option)

SforceServiceStub stub = new SforceServiceStub();
LoginDocument ld = LoginDocument.Factory.newInstance();
Login l = Login.Factory.newInstance();
l.setUsername(args[0]);
l.setPassword(args[1]);
ld.setLogin(l);
LoginResult lr = stub.login(ld).getLoginResponse().getResult();

Yes, that really is 7 lines of code for the new and improved version vs 2 lines of code originally. Don't think I'm picking just on axis2, WCF is equally dumbass (to the point where one of the Indigo evangelists eventually backed down and said that the existing .NET WS stuff is better than Indigo for calling regular WS-I basic profile services!). Moving on in the code, the stub no longer tracks headers for you, each operation that takes soap headers has to have the set of headers passed into every operation. I can't imagine anyone using this stuff without writing an additional wrapper class that exposes an model like the earlier versions of the tools.