Comparison of advantages and disadvantages of various combinations of WSDL binding styles

Source: Internet
Author: User

Currently, the relevant standards for Web Services are WSDL [Web Service Description Language], a standard language similar to XML schema, it is used to describe in detail the web service and soap [Simple Object Access Protocol]. The actual communication protocol used by the Web Service is soap. The WSDL Binding style is composed of two attributes: style and use; style can be rpc/document, and use can be encoded/literal. The following describes the meanings of the four nouns:

RPCStyle

The RPC style specifies that the <soap: Body> element contains the name of a web method to be called (wrapper element (encapsulation element )). This element records each parameter of the method and the return value in sequence.

Document Style

If it is a document style, there is no wrapper element like in the RPC style. Instead, message fragments appear directly under the <soap: Body> element. There is no soap formatting rule that specifies what the <soap: Body> element can contain. It contains an XML document that is consistent between the sender and receiver.

Encoded Encoding 

If the value of use is "encoded", each message segment usesTypeAttribute to reference the abstract type. ByEncodingstyleThe encoding style specified by the attribute. You can use these abstract types to generate specific messages. The most common soap encoding style is a set of serialization rules defined in soap1.1, which describes how objects, structures, arrays, and graphic objects should be serialized. Generally, the use of soap encoding in applications focuses on remote process calls and later RPC message styles.

Literal text? 

If the value of use is "literal", useElementAttribute (for simple snippets) orTypeAttribute (for composite fragments) to reference a specific architecture. For example, data is serialized Based on the specified architecture, which is usually expressed using the W3C XML architecture.

Four binding models are formed based on different combinations. In addition, it is also common to use document to simulate RPC-style packaging combinations;

  1. RPC/encoded
  2. RPC/literal
  3. Document/encoded
  4. Document/literal
  5. Document/literal wrapped

For the above five combination methods, since document/encoded is not supported by the existing platform and is rarely used in practice, this combination is not discussed here; for the remaining four combinations, we use a table and an instance to compare their advantages and disadvantages;

Binding type Advantage/disadvantage
RPC/encoded Advantages:

  1. The definition of the WSDL File follows an intuitive and well-known communication mode for remote process calls.
  2. The operation name is displayed in the message, so the receiver can easily assign the message to it.
  3. If you are using data graphics or polymorphism in your service, this is the only style that can be used.

Disadvantages:

  1. The Type encoding information contained in a SOAP message is like xsi: TYPE = "XSD: int", which is an overhead.
  2. It is usually difficult to verify the SOAP message because it is not described in the WSDL shcema.
  3. The RPC style causes a close coupling between the service provider and the customer. Any changes to the interface will interrupt the connection between the service and the customer.
  4. It is not supported by the WSI consistency standard.
RPC/literal

Advantages:

  1. The WSDL definition is still as simple and straightforward as the RPC/encoded style.
  2. The operation name still appears in the SOAP message.
  3. The Type encoding is excluded from the message, thus improving the throughput performance.

Disadvantages:

  1. The service is still tightly coupled with the customer.
  2. It is still difficult to use soap messages to verify transmitted data.
  3. It is not supported by the WSI consistency standard.
Document/litaral

Advantages:

  1. There is no type encoding information in the SOAP message.
  2. You can always use any XML validators to verify messages. Everything in the soap body is defined in the schema.
  3. When the document style is used, the rules are not so strict, and the interface is not damaged when the XML schema is enhanced or changed.
  4. If a special sequence is used for multi-process calling, the document style can maintain the state of the application.
  5. The document style is more suitable for asynchronous processing.
  6. Many document-messaging services can select one of the two Processing Methods of the document Dom and sax, and the result is to minimize the processing in the memory.

Disadvantages:

  1. The definition of WSDL becomes more complex.
  2. If the operation name in a SOAP message is absent and the name is absent, it becomes difficult or impossible to assign the message to it.
Document/literalwrapped

Advantages:

  1. It includes the advantages of all document/literal styles.
  2. The operation name appears in the SOAP message.

Disadvantages:

  1. Even if the definition of WSDL becomes more complex, there are still many disadvantages.
  2. If you reload operations in the Web service, you cannot use this style.

Assume that the method of WS to be called is public void mymethod (int x). The WSDL/soap fragments generated by various binding styles are as follows:

Binding type WSDL Soap
RPC/encoded
<message name="myMethodRequest"><part name="x" type="xsd:int" /></message><message name="empty" /><portType name="PT"><operation name="myMethod"><input message="myMethodRequest" /><output message="empty" /></operation></portType><binding><!-- RPC/encoded. --></binding>
<soap:envelope><soap:body><myMethod><x xsi:type="xsd:int">5</x></myMethod></soap:body></soap:envelope>
RPC/literal
<message name="myMethodRequest"><part name="x" type="xsd:int" /></message><message name="empty" /><portType name="PT"><operation name="myMethod"><input message="myMethodRequest" /><output message="empty" /></operation></portType><binding><!-- RPC/literal. --></binding>
<soap:envelope><soap:body><myMethod><x>5</x></myMethod></soap:body></soap:envelope>
Document/litaral

<types><schema><element name="xElement" type="xsd:int" /></schema></types><message name="myMethodRequest"><part name="x" element="xElement" /></message><message name="empty" /><portType name="PT"><operation name="myMethod"><input message="myMethodRequest" /><output message="empty" /></operation></portType><binding><!-- document/literal. --></binding>

<soap:envelope><soap:body><xElement>5</xElement></soap:body></soap:envelope>
Document/literal wrapped

<types><schema><element name="myMethod" /><complexType><sequence><element name="x" type="xsd:int" /></sequence></complexType></element></schema></types><message name="myMethodRequest"><part name="parameters" element="myMethod" /></message><message name="empty" /><portType name="PT"><operation name="myMethod"><input message="myMethodRequest" /><output message="empty" /></operation></portType><binding><!-- document/literal. --></binding>

<soap:envelope><soap:body><myMethod><x>5</x></myMethod></soap:body></soap:envelope>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.