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.



  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.

Quick Notes Finder Tags

Activities (1) advanced java (1) agile (3) App Servers (6) archived notes (2) ArrayLists (1) Arrays (2) Best Practices (12) Best Practices (Design) (3) Best Practices (Java) (7) Best Practices (Java EE) (1) BigData (3) Chars & Encodings (6) coding problems (2) Collections (15) contests (3) Core Java (All) (53) course plan (2) Database (12) Design patterns (8) dev tools (3) downloads (2) eclipse (9) Essentials (1) examples (14) Exception (1) Exceptions (4) Exercise (1) exercises (6) Getting Started (18) Groovy (2) hadoop (4) hibernate (77) hibernate interview questions (6) History (1) Hot book (5) http monitoring (2) Inheritance (4) intellij (1) java 8 notes (4) Java 9 (1) Java Concepts (7) Java Core (8) java ee exercises (1) java ee interview questions (2) Java Elements (16) Java Environment (1) Java Features (4) java interview points (4) java interview questions (4) javajee initiatives (1) javajee thoughts (3) Java Performance (6) Java Programmer 1 (12) Java Programmer 2 (8) Javascript Frameworks (1) Java SE Professional (1) JPA 1 - Module (6) JPA 1 - Modules (1) JSP (1) Legacy Java (1) linked list (3) maven (1) Multithreading (16) NFR (1) No SQL (1) Object Oriented (9) OCPJP (4) OCPWCD (1) OOAD (3) Operators (4) Overloading (2) Overriding (2) Overviews (1) policies (1) programming (1) Quartz Scheduler (1) Quizzes (17) RabbitMQ (1) references (2) resources (1) restful web service (3) Searching (1) security (10) Servlets (8) Servlets and JSP (31) Site Usage Guidelines (1) Sorting (1) source code management (1) spring (4) spring boot (3) Spring Examples (1) Spring Features (1) spring jpa (1) Stack (1) Streams & IO (3) Strings (11) SW Developer Tools (2) testing (1) troubleshooting (1) user interface (1) vxml (8) web services (1) Web Technologies (1) Web Technology Books (1) youtube (1)