Web services guest bile
Thursday, November 24th, 2005Today’s entry is a guest bile courtesy of Mr Clean. The submission was edited slightly to match the high standard of pottymouthed gibberish you’re all used to, so the disruption in style and content should be minimal.
—
You are a developer, and we want to stab you in the genitalia with a wooden spoon. We never much cared for the nitty-gritty of coding, so instead we represent our company on the W3C, because it’s fun, exciting, and saves us from actually having to use anything in the real world. You know you can trust us, who else would come up with anything as clever as the DOM API? You on the other hand have stuck to menial development, wearing out braces and semicolons on your rubbery keyboards, and for that, we laugh, point, and fling wet bottomburps in your general direction.
You are powerless to stop us. Powerless we say! Your plan to “put a web service in front of it, should be relatively easy, a few days max.” will rank alongside “this is the Titanic, we don’t swerve for icebergs”, and “a short occupation quickly leading to an independent democracy in Iraq with soldiers worrying about candy and flower related injuries”, in the Naivety Hall of Fame.
Let’s start with WSDL - Web Service Duplication Language. The schema says it is the product of IBM and Microsoft, so you will anticipate some typing will be needed. This is confirmed as you navigate from the schema element, to message with it’s parts, to the portType with operations and inputs and outputs, to the binding with it’s own with operations, and inputs, and outputs. “Boy,” you think, “I bet this is really flexible, glad they did not make things more direct!”. All of these have names, and a simple process of trial and error will show you which names have to refer other names, and which are going to end up in the generated Java. If we used the relational constraints features in the schema for WSDL, that would make things too obvious, thus minimising the fun and challenge of the whole endeavour.
Namespaces in XML are good, so more namespaces must be better. WSDL has many, and these can be especially fun when dealing with the output of a WSDL generator or an IDE. Let’s use the same URI for different things, and for the hell of it, let’s confusingly use the same names for messages and suchlike so you’ll never figure out the cardinalities and relationships. XML being human readable is an outdated concept anyway, and a string of gibberish characters is just as good these days. What they lack in coherence they can make up for in verbosity.
Let us turn to the Java aspects and JAX-RPC. Now, what you want to do is bind the entire XML structure to generated Java classes. Yes you do. No really. Binding is the one true path. Any XML Schema can be bound to Java classes, unless the schema does something silly, like use the features of schema to produce a well designed, tight schema. What was the W3C thinking, designing schema for documents, instead of just remote procedure calls? XML for documents? Why would anyone do that?
The schema will be nice and small anyway, because web services are always used for stock tickers. Anything else is out of scope. You have a stock symbol and a price and that can easily be bound to a few small Java classes. An intelligent young gentleman like yourself would not try to use a complicated schema, now would you? What is that you say? “The format and schema to be used are already defined”? Oh, we are in a pickle. Hope that schema is not an industry standard, designed by a committee, where everyone gets a go at putting a feature in. We would not like to work with an object model like that in our Java. It is not like you can write or have already written your own parsing functionality. No, binding is the one true path.
Why the fixation with XML binding? We created the glorious JAXB, and you snivelling runts ignored it. Well, now you will have no choice. You have your business objects, and you have your XML. So naturally what you need is another separate bunch of Java objects, bound to the schema, which you can navigate to copy the data into your business objects. A one megabyte, industry standard, pile of crap schema becomes twenty megabytes of lovely JAXB source. There are lots of
crappy names and packages, and classes for anonymous schema types. Do not ask us for a DOM, you weakly-typed peon. You may however have SOAPElement objects, provided you hack the WSDL in an implementation specific way, and are prepared to deal with old versions of this
bastard child of JAXM called SAAJ, that are completely separate from the normal Java APIs like DOM. Actually, lets then make a new version which does extend all the DOM crap, because we can. Now that we’ve managed to sucker a bunch of you into using JAXB, we’ve identified the idiots for the smart people. We can now go ahead and introduce JAXB2, which is aimed at the less braindamaged of you despicable developers.
Why use old versions of the SOAPElement classes? Well, J2EE 1.4 is a bit new, now isn’t it? So you are stuck on Websphere 5.x or Weblogic 8.1. (not one of the poor peoples app. servers), and there is no J2EE standard for web services in those. So now you get to learn how (or whether) IBM and BEA programmers think, and you must code accordingly. Dreams of reuse evaporate. You could try switching in an alternative SOAP library, with all the endless hilarity that that entails. You could try using SAAJ and forego JAX-RPC, but you must deal with more factory construction than southern China, and SAAJ does not tell you how to hook-up a service implementation in J2EE, just how to call one. SAAJ is fact is baffling in its pointlessness, all in all.
JAX-RPC will be better in version 2.0. We have changed the name, but not because we rogered the first versions and there is a stigma. It can’t be any worse, so we can guarantee gratitude and praise. You are a developer, and we want to stab you in the genitalia with a wooden
spoon.