World Wide Webber


My Books
REST in Practice: Hypermedia and Systems Architecture
Amazon:
US, UK
Developing Enterprise Web Services by Sandeep Chatterjee and Jim Webber
Amazon:
US, UK,
Also available: Korean Edition

My Bookshelf
RESTful Web Services Cookbook by Subbu Allamaraju
Programming Clojure by Stuart Halloway
RESTful Web Services by Leonard Richardson and Sam Ruby
Doc/Literal Wrapped Makes No Sense
Posted: 19 August 2004 @ 14:13 UT from Sydney, Australia

"Chewbacca is a Wookiee from the planet Kashyyyk who carried a gun and ran from the mob. But Chewbacca lives on the planet Endor. Now think about it. That does not make sense. Why would a Wookiee, an eight-foot-tall Wookiee, want to live on Endor with a bunch of two-foot-tall Ewoks. That does not make sense." [South Park]

Like a recurring bad dream I keep seeing this Chewbacca-esque document/literal wrapped convention being banded around (first pointed out to me in this IBM article - thanks Nigel!). Essentially it is a document (as in no method name), literal (as in uses its own schema) and then wrapped (as in, "oh yeah we really want a method name but we have to do doc/literal because RPC is bad"). For example, consider the following message definitions:

<!-- For rpc/literal -->
<message name="FooRequest">
  <part name="param" type="xsd:string"/>
</message>
<!-- For doc/literal -->
<types>
  <schema>
    <element name="Foo" type="xsd:string"/>
  </schema>
</types>

<message name="FooRequest">
  <part name="param" element="Foo"/>
</message>
<!-- For doc/literal + wrapped -->
<types>
  <schema>
    <element name="Foo"/>
      <complexType>
        <sequence>
          <element name="param" 
            type="xsd:string"
            minOccurs="1" maxOccurs="1"/>
        </sequence>
      </complexType>
    </element>
  </schema>
</types>

<message name="FooRequest">
  <part name="parameters" element="Foo"/>
</message>

And the following portType declaration:

<portType name="FooPT">
  <operation name="Foo">
    <input message="FooRequest"/>
  </operation>
</portType>

We get the following (pseudo) on-the-wire forms:

<!-- For rpc/literal -->
<Foo>
  <param>string</param>
</Foo>
<!-- For doc/literal -->
<Foo>
  string
</Foo>
<!-- For doc/literal + wrapped -->
<Foo>
  <param>string</param>
</Foo>

How annoying is that? Effectively doc/lit + wrapped is the same as rpc/lit with the exception that to get doc/lit + wrapped you have to do some unnatural things to your service's WSDL contract.

This does not make sense.

Your WSDL document should model the structure and exchange patterns of the documents exchanged in your real-world system, and should not be hacked like this to make your deficient Web Services tooling work! If you have to do this, you need to change your SOAP stack (and probably your project architect).

Use document/literal and let your service implementation work out how to dispatch the incoming message. It's none of the consumer's business how things get dispatched internally, so it doesn't make a great deal of sense to advertise your dispatch mechanism to the consumer (which is what rpc and document/literal + wrapped effectively do) only then to have consumers tell you how they want things dispatched in each message they send (yes Mark, before you ask I did read your comments :-)

Of course if you want to increase the level of coupling between consumers and services then this is a great way to do it...

Comments:
#
Alright jim It's jonny here (the lanky one who drinks all the coke ;-) Hope you don't mind me butting in on this one, but I've been doing some work on web services and different styles and I quite like wrapped to be honest, forgive me if I'm a little naive please :-)... While I understand using wrapped works against the whole doc/lit ideology (define messages that represent their application layer use), the fact is that a large number of w.s. programmers will deploy services using w.s. platforms that push programmers into using an RPC programming model anyway (but still using doc/lit, e.g. Microsoft.NET). i.e. programmers will define methods and parameters and these will be mapped, by the platform, to a WSDL description and consequently a SOAP message structure will have been forced upon them. In this case, you are effectively relinquishing control of what should be application layer message structuring and pushing in into the w.s. platform. So if you've done this then does it make any difference if SOAP messages have been structured in a way that you didn't expect?...after all doc/lit specifies nothing about structuring, other than anything is valid. Have you read this Microsoft paper (RPC/Literal and Freedom of Choice)? They argue in here, for doing everything using doc/lit & wrapped... http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwebsrv/html/rpc_literal.asp Of course, if you're doing things the proper way, you shouldn't be using wrapped at all, but then how many people using doc/lit are actually building WSDL themselves? Perhaps Microsoft viewed the ability to structure doc/lit messages how they liked as a green card to slightly deviate from de facto structuring and mess everyone else up?! (i.e. JVM, HTML etc) jonny.
#
Hey Jonny, Long time no hear - hope things are going well. You won't be suprised to hear that I think doc/lit + wrapped makes no sense. In the RPC-like case that you describe, the value is in interoperability. If you use SOAP-RPC then you won't interop with anyone else's SOAP stack (do you remember when Paul R. and I were trying to get HP's SOAP stack to interop with MS's?). In this case you get SOAP-RPC like semantics, but you leave interop to the developer(s). So if you're building RPC using WS technologies, this might be valid. However if you're using WS technology to build RPC-like systems then you're missing the point: there are better RPC systems than Web Services. Catch you later. Jim
#
Hallo Jim, not doing too bad cheers, doing the SDIA course at the moment, it's getting close to crunch time so I should get back to my Word document! From your site, I see you're in Sydney...very nice! Yes I agree doing RPC with doc/lit misses the point of doc/lit and its like trying to design user interfaces in prolog (well not quite). Though from what I've seen you do get a couple of nice benefits by using doc/lit for doing RPC: the ability to fully XML schema (which I know you can do with RPC/lit), and the ability to do full schema validation without any messing about. But then I hear WS people aren't really interested in schema validation cos it's too slow (I think?). But do you know what happened to Microsoft when they were choosing their default message format/encoding style? Have they been smoking too many of the strange looking cigarettes?! Cheers, jonny.
Author Name:
Email:
Author URL:
Comment:
Antispam:
Please type the following string (note that if the strings don't match, your comment will be lost... sorry!): 'GMTQK'.
 
Recent entries

Recent comments

Feeds:
RSS 2.0 Atom