SOAP Binding Styles - DOCUMENT and RPC

SOAP Binding can be done using two styles: DOCUMENT and RPC. This is denoted in the wsdl as style in the binding section. 

The @SOAPBinding annotation can be used over an SEI (separate interface or class) to configure the soap binding styles, when developing a web service bottom up. Default is DOCUMENT. Annotate the SEI with @SOAPBinding(Style=Style.RPC) to get the RPC style. Generate a wsdl both with DOCUMENT and RPC styles and refer to them in parallel while going through these notes.

 

DOCUMENT style

  1. SOAP messages will contain full XML documents.

  2. The types section holds, points to, or imports an XSD.

    • Document style can hence support services with rich, explicitly defined data types.

  3. In unwrapped document style, the SOAP message does not carry the name of the service operation. 

    • The wrapped document convention provides a way to name the body of the SOAP message after the corresponding service operation.

      • The parameter style attribute of the @SOAPBinding annotation can also be used to specify if the document parameters should use wrapped style or unwrapped stye.

  4. Can support any service pattern.

  5. From an architectural perspective, the document style is simpler as the body of the SOAP message is a self-contained with XSD.

 

Annotations for DOCUMENT style

Document style is the default SOAP Binding style, but can also be explicitely set using the @SOAPBinding annotation.

 

RPC style 

  1. SOAP messages contain parameters in the request messages and return values in the response messages.

  2. The types section is empty, as the service return only simple types.

    • XSD is not used for defining types.

  3. the messages carry the names of the @WebMethods operations.

  4. Supports only request-reply.

  5. From developer perspective, rpc is simpler

    • wsgen utility is not required to generate java types that correspond to XML schema.

 

Annotations for RPC style

You can use the @SOAPBinding annotation to change the style to RPC

  • default is DOCUMENT 

You can use @WebParam annotation before a method argument to give a different name for the input argument.

You can use @WebResult annotation above a method to to give a different name for the output.

 

Advantages of document style

  1. The body of a SOAP message can be validated against the XSD given in the types section of the WSDL.

  2. A service in document style can use rich data types.

  3. There is a great flexibility in how the body of the SOAP message is structured as the structure is clearly defined in an XSD.

  4. The wrapped document convention provides a way to add the major upside of rpc style to document style, which is naming the body of the SOAP message after the corresponding service operation.

 

Limitations of document style

  1. In unwrapped document style, the SOAP message does not carry the name of the service operation, which can complicate the dispatching of messages to the appropriate program code.

  2. The wrapped document style adds a level of complexity, in particular at the API level. Writing a client against a wrapped document service can be more challenging.

  3. The wrapped variant does not support overloaded service operations because the XML wrapper element in the body of a SOAP message must have the name of the service operation. In effect, then, there can be only one operation for a given element name.

 

Advantages of RPC style

  1. The automatically generated WSDL is relatively short and simple because there is no types section.

  2. Messages in the WSDL carry the names of the underlying web service operations by default, which are @webMethods in a java-based service. The WSDL thus has a what-you-see-is-what-you-get style wrt the service’s operations.

  3. Message throughput may improve because the messages do not carry any type encoding information.

 

Limitations of RPC style

  1. The WSDL, with its empty types section, does not provide an XSD against which the body of a SOAP message can be validated.

  2. The service cannot use rich data types because there is no XSD to define such types.

  3. Since RPC is associated with the request /response pattern, it encourages tight coupling between server and the client.

  4. Long term support for rpc from web services community and the WS-I group is doubtful.

 

We will see more about @SOAPBinding annotation and additional SOAP Binding attributes.

Also, do the labs and read these notes again for a better understanding.

Search the Web

Custom Search

Searches whole web. Use the search in the right sidebar to search only within javajee.com!!!