SOA / Web Services / Java

A Technology Blog

RPC-style vs Document-Style Web Service

Posted by Vivek on September 12, 2008

There has been lot of confusion on which style of web service is used but It is always recommended to use a Document-style webservice to realize SOA.

RPC style web service:
These web services are easier to create and are usually synchronous in nature.
The responsibility of marshalling and de marshalling lays with SOAP engine, This leads to significant performance degradations when message passed to an operation is large or complex.
Since large sized messages lead to performance degradation in RPC style web service, they are not suitable for implementing coarse grained functionality requiring information messages having more number of fields.
However fine grained functionalities is better implemented by RPC style web services.
Document style web service:
Document style web services are more time consuming to create, as it is the onus of the service to create the required objects from XML document.
These web services can consume large sized documents without any significant drop in performance as there are no overheads of marshalling and de marshalling associated with SOAP engine.
Document style web services are ideal for representing coarse rained functionality as a single large sized  document can be used to transfer information required to implement a business functionality.
Document style web service are primarily used for implementing asynchronous service.

RPC encoded web services are easiest  create but offers least control in terms of usage of custom data types, validation and interoperability.
RPC encoded web service are slower in performance because of added overheads of marshalling and un marshalling.
Document literal web services are harder to create but scores higher in all the above metrics and this is one of the reasons WS –I basic profile encourages the usage of document literal web services.

Document style web services are better suited for defining custom data types as they are not constrained by the usage of a particular encoding style. Document –literal web services offers the best performance and RPC –encoded web services offers the least performance as in document-literal web service overheads of marshalling and un marshalling no longer lies with SOAP engine. In a document –literal web service alternative techniques such as  SAX based parsing or custom data binding tool like XML beans, castor can be used.In case SOAP engine does not maintain state a document –literal web service can be used to carry state related data in the document. While using RPC –encoded web service often platform specific data structures are exposed in WSDL, which might not be supported by other platforms.


10 Responses to “RPC-style vs Document-Style Web Service”

  1. Rohit Seth said

    very clear explanation of when to user RPC based or document literal webservice. Many Thanks.


  2. […] Document Style Versus Procedure Style: […]


  3. Gregg Wonderly said

    This is nuts, if you send an XML document, you have to parse it and do field extraction to get to the encapsulated data. It doesn’t matter what layer or what part of the system does this. You will have to pay for the latency of that extraction and it will be part of your systems stability and efficiency, always.


  4. WS-SME said

    I believe mentioning about marshaling and un-marshaling processes as an overhead for RPC style web services is referring to some encoding mechanism such as type encoding (i.e. xsi:type=”xsd:int”) which degrades throughput performance.


  5. makeup case…

    […]RPC-style vs Document-Style Web Service « SOA / Web Services / Java[…]…


  6. Deepak said

    Good article for knowing the soap binding style.


  7. […] […]


  8. javaexp said

    beginners usually tend to use Document style web services blindly. you have put a very strong point against Document style regarding extra processing required. some more points on difference between RPC and Document style web services


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: