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.
Rohit Seth said
very clear explanation of when to user RPC based or document literal webservice. Many Thanks.
LikeLike
SCDJWS 5 (310-230) « vignesh's Blog said
[…] Document Style Versus Procedure Style: http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/ http://www.ibm.com/developerworks/webservices/library/ws-docstyle.html http://oracled.wordpress.com/2008/09/12/rpc-style-vs-document-style-web-service/ […]
LikeLike
Deepak said
Good catch for ibm references.
LikeLike
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.
LikeLike
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.
LikeLike
Vivek said
I concur.
Probably this is the article that you referred to – http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/
It is a well written article on why to use Literal.
LikeLike
makeup case said
makeup case…
[…]RPC-style vs Document-Style Web Service « SOA / Web Services / Java[…]…
LikeLike
Deepak said
Good article for knowing the soap binding style.
LikeLike
RPC-style vs Document-Style Web Service « myworldofjava said
[…] http://oracled.wordpress.com/2008/09/12/rpc-style-vs-document-style-web-service/ […]
LikeLike
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
LikeLike