Saturday, May 11, 2013

RPC Vs Document Literal Style

Recently I have been reading Martin Kalin's Java Web Services Up and Running. The book does an excellent job explaining how to use Jax-WS/Metro to create web services clients and/or servers.  However the book does end up to be a bit confusing when explaining the difference between Document/Literal Wrapped vs Document Literal Unwrapped style. Initially I thought it was a problem with my understanding, but it turn's out I am not the only one, see the conversation here. Page 44, gives examples of requests that are generated for unwrapped and wrapped styles. However on page 54 when taking about wrapped vs unwrapped styles, it says, 
What may be surprising is that the structure of the underlying SOAP messages, both the request and response remains unchanged.
So why does page 44 conflict with page 55? I believe the confusion is arising because the book is talking about two different concepts,
  • WSDL Bindings
  • Jax-WS  Client Code Generation 
WSDL Bindings From pages 38-46, the discussion is on WSDL bindings. This is a generic discussions on different types of bindings possible. IBM developerWorks  also has an excellent article on this here. Basically there are 4 different combinations of style and use possible
  • document/literal
  • rpc/literal
  • document/encoded
  • rpc/encoded
All are valid styles for a WSDL. We now need to bring in a specification referred to as WS-I. This specification
  • attempts to define a standard that allows web services to be interoperable and is supported by Jax-WS, .Net and axis frameworks.
  • allows for only document/literal and rpc/literal based services.
  • enforces that the element can have only one child. This restriction creates problems for document/literal based services.
This means that the unwrapped soap request like the one on page 44 is not WS-I standard compliant. The parameters have to be wrapped. Jax-WS Client Code Generation Starting page 54, the book explains client code generation. The point here is that the wrapped/unwrapped in this section refers to the code generated. It should not be confused with style/use of WSDL bindings. If you see the WSDL, you will find that the the WSDL follows document/literal wrapped style/use. So irrespective of how the code generated (wrapped or unwrapped) it should generate the same soap request.

No comments: