SOAP vs POX Debate, Part One

This time in San Francisco for the JavaOne 2007 conference, Adrian Trenneman deliberately tracked Ted Neward down at one of the innumerable “after-parties”–this one hosted by some company whose name sounded something like “oogle”–and started up another conversation, this time on the growing debate between “SOAP” and “Plain Old XML”, or “POX”. Once again, TheServerSide was able to capture the discussion, despite the best efforts of several large men in black suits and sunglasses who kept interrupting the early parts of the conversation with brusque challenges of “Continue or Cancel?”. Rumor has it these “G-Men” are part of a new multinational intelligence organization, but that’s another story for another day.

(Editor’s note: Again, as with the prior conversation, both men had consumed many of the available beverages of questionably moral character, and were still a touch irritated at the “G-Men” trying to display advertising in the background of their conversation. Readers unaccustomed to raucous debate are, again, forwarned.)

Adrian: Ted!

Ted: (in his best “Rocky Balboa” voice) Yo, Adrian!

Adrian: Har, har.

Ted: Sorry, man, couldn’t resist.

Adrian: Hey, did you see that our conversation in London was recorded somehow?

Ted: Yeah, I saw that–did you do that?

Adrian: No, I thought you did. Weird. Oh, here’s another waiter with wine. You want one?

(Mumbled deep voices interrupt the tape here, sounding vaguely like “Please talk into the lapel” and “Continue or Cancel?”)

Adrian: So I wanted to ask you about this SOAP vs. REST thing that’s going around.

Ted: Oh, boy, here we go again.

Adrian: (Laughs) What, you didn’t have fun last time?

Ted: (Laughs) OK, SOAP vs REST, though I think we’re better off characterizing it as a “SOAP vs POX” debate.

Adrian: Ah yes - Plain Old XML. Funny that. You’d have thought that soap would be just the cure for the pox.

Ted: Yup, strange but true: there is actually a whole lot of Plain Old XML out there -in other words, just ignore the SOAP part of things and just send XML back and forth with nothing surrounding it.

Adrian: See, that’s just it. I’ve been musing about this for the last few days. I remember the pain in the early days of SOAP, when the spec included it’s own “SOAP-encoding”…

Ted: Agh! Don’t ever bring that name up to me again!

Adrian: Huh?

Ted: SOAP-Encoding was such a POS, that…

Adrian: POS? Plain Old String?

Ted: No, Piece of Sh*t.

Adrian: (Laughs) Sorry, thought we’d coined a new acronym there.

Ted: Anyway, as near as I can tell, SOAP-encoding was an almost-afterthought part of the spec, designed to be a quick-and-dirty way of transcribing objects into XML and back again, and had holes large enough to drive a Mack truck through. When I’d heard the WS-I guys deprecated SOAP-encoding entirely, I danced the HappyHappyJoyJoy dance for hours.

Adrian: I hear ya. I was still young then. I had more hair. Hmmm. Hair loss due to Interop problems. Can I claim that on health insurance?

(Ted sighs and does his impression of a drum role at a comedy gig).

Adrian: I remember pain around bloated payload, and lots of interop issues around arrays. You’d think they could have figured it out…

Ted: Yeah - but there’s some even deeper issues here, one being that objects and XML have just as deep an impedance mismatch as objects and relational data do.

Adrian: You’ve mentioned that before Ted - sure there’s a mismatch. But hey, let’s not throw the baby out with the bath water!

Ted: On the contrary, lets! Look - consider this simple object model, represented by this class.

Adrian: Is that Java or C#?

Ted: There’s a difference?

Adrian:Point taken. OK, you have this class, now what?

Ted: Well, OK, assume I’ve created a couple of objects, like so:

Adrian: Who’s Jay and Libby?

Ted: They run the No Fluff Just Stuff shows. Nice folks.

Adrian: Ah.

Ted: Anyway, so now I want to pass Jay as a parameter in an XML service call. What should the corresponding XML look like? Before you answer, let me run you through the usual suggestions. The first says that fields just map to child elements, and you follow the references accordingly.

Adrian: OK, sounds good, but…

Ted: I know, but hang on. If I do that, we run into a problem pretty quickly, right?

Adrian: Ouch. I hear ya. No way to encode references.

Ted: Yep. Because XML isn’t designed to be recursive in nature–it’s just a tree-based data structure–it has a really hard time dealing with these kinds of recursive object models, which happen all the time in object designs.

Adrian: So what’s this got to do with SOAP-encoding?

Ted: Well, the SOAP guys initially tried to solve this problem, by creating an encoding mechanism on top of the XML structure–

Adrian: The Infoset.

Ted: –right, on top of the Infoset, so it would look something like this:

which, of course, isn’t valid XML, but to them, that was OK, because they’d surround this with an outer element anyway.

Adrian: So what was wrong with it?

Ted: Well, for starters, how do you write an XPath query to find the spouse of the spouse of the person named Jay?

(Long pause.)

Adrian: Um, I can’t think of one.

Ted: Right–that’s because this is encoded on top of the Infoset, and all the various X-languages and tools are designed to work with the Infoset, not on top of it. Second, imagine what happens if we have a graph of over a hundred objects referenced from Jay? What happens when he gets passed in?

Adrian: Oh, yuck–they’d all get serialized in, don’t they?

Ted: Yep, and you end up passing a lot more data across the wire than you’d originally intended or wanted.

Adrian: So was that it?

Ted: Oh, no, there was more–what happens if you get an error in transmission, such as something like this?

Adrian: Well, I’d imagine you’d find this out when you try to recreate the object graph, right? You can’t create a Pet object and store it into a Person reference, I would think.

Ted: Sure, but (a), you’re only going to get this error after you’ve parsed the entire XML graph and instantiated a bunch of those objects, and (b) what about those languages that aren’t object-oriented?

Adrian: You mean there are languages that aren’t object-oriented? Seriously?

(Both men laugh)

(Editor’s note: At this point, one of the G-men stepped in, mumbled “Continue or Cancel?”, and while Ted and Adrian discussed programming languages for a while, our agent was forced to disguise himself as a plastic plant.)

Read Part 2


Leave a Reply