Tuesday, December 27, 2005

Web Services - RPC Vs Document

For Beginners, RPC Style Vs Document Style would be confusing.

Mitch has done a good job of clarifying it in his article.

A Distinction has been made between Communication Pattern and Style.

Excerpt:

we turn to the two decisions for formatting the contents of a message's element.

The style, or binding style, decision controls how the elements just under the SOAP body are constructed. The two choices are:

  • RPC: Add extra elements to simulate a method call. (Note that RPC is also a communication pattern.)
  • Document: Just send the XML as is. There's also a variation called wrapped that is still specified as document.

Here's an example of an RPC-style message:




0000000000
000000000B



RPC relies on some rules. Observe that the root element is qualified with a namespace, but the two child elements use unqualified names. The root element is named after the operation: opName for a SOAP request, opNameResponse for a SOAP response. Each child is a parameter, or a return value named opNameReturn.

Now here's an example of a document-style message:



test



Observe that all elements are defined within the same namespace. With a document-style Web service, you're free to define the XML however you wish because all the XML is explicitly specified.

Next, we examine how binding style is specified in the WSDL. There actually is a style attribute in the element, which is the element's first child. Also, each nonempty has one or more child elements, into which style factors.


Table 1. How binding style is specified in a WSDL document

RPCDocument
elementstyle="rpc" style="document"
element(s) Any number of elements, each containing a type attribute Single element containing an element attribute; zero also allowed






A WSDL document provides the interface (a generic "list of methods") and a set of instructions that describe how the service is bound to a messaging protocol.

The WSDL 1.1 specification distinguishes two different binding styles, as follows:

* RPC Style: This style specifies that the contains an element with the name of the service method being invoked (the wrapper element). This element, in turn, contains an entry for each parameter and the return value of this method.

* Document Style: In this style, there is no wrapper element. Instead, the message parts appear directly under the element. There are no SOAP formatting rules for what the contains. The contains what the sender and receiver agreed on as an XML document.

Within those styles, you can also have an encoded use or a literal use:

* Encoded: In this use, each message part references an abstract type using the type attribute. The message is produced using an encoding specified by the encodingStyle attribute. The encoding most frequently used is SOAP Encoding, which is a set of serialization rules defined in SOAP 1.1. The rules specify how objects, structures, arrays, and object graphs should be serialized. In general, applications that use SOAP encoding focus on remote procedure calls, and likely use the RPC message style.

* Literal: In this use, each part references a concrete schema definition using either the element or type attribute. In other words, data is serialized according to a given schema. In practice, this schema is usually expressed using W3C XML Schema.

To summarize, the binding style/use combinations are:

* RPC/encoded
* RPC/literal
* Document/encoded
* Document/literal

Refer to this JDC Tip

Websphere - Utility Jar

At times, We need to reference some jar files from more than 1 web/ejb module.

This article suggests different ways to achieve the same in WSAD/RAD.

Web Services - What a Pain it is to work with?

Anyone who has tried to develop Web Services with J2EE/.NET would attest to the fact that it is too messy. Too Many Specs..

Read this bileblog entry to understand it better....