Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

when to use SOAPBinding.ParameterStyle.BARE and SOAPBinding.ParameterStyle.WRAPPED

I am in confusion as when to use SOAPBinding.ParameterStyle.BARE and SOAPBinding.ParameterStyle.WRAPPED .and which binding style is more preferred.what are the differences between them.

like image 499
sRaj Avatar asked Jan 17 '14 16:01

sRaj


2 Answers

ParameterStyle.Bare and ParameterStyle.Wrapped affects your wsdl definitions of request and response messages only.

Lets take an example, we have a webservice with a method "test" which has 2 input "string1" and "string2" and it is returning a string as "rstring".

ParameterStyle.BARE Your parameter's name will be visible as part name in your wsdl.

Request message:

<message name="test">
<part name="string1" element="tns:string1"/>
<part name="string2" element="tns:string2"/>
</message>

Response message:

<message name="testResponse">
  <part name="rstring" element="tns:rstring"/>
 </message>

In your xsd test and testResponse will be defined like below, and your wsdl element directly referring elements under test and test response from xsd.

<xs:complexType name="test">
   <xs:sequence>
       <xs:element name="string1" type="xs:string" minOccurs="0"/>
       <xs:element name="string2" type="xs:string" minOccurs="0"/>
   </xs:sequence>

<xs:complexType name="testResponse">
   <xs:sequence>
       <xs:element name="rstring" type="xs:string" minOccurs="0"/>
   </xs:sequence>

ParameterStyle.WRAPPED

In this style your request and response message will be wrapped in single input as "parameter" and output as "result". and they will refer that particular element in xsd for all elements within.

Request message:

 <message name="test">
 <part name="parameters" element="tns:test"/>
 </message>

Response message:

  <message name="testResponse">
     <part name="result" element="tns:testResponse"/>
 </message>

In your xsd test and testResponse will be defined as same as above,

<xs:complexType name="test">
   <xs:sequence>
       <xs:element name="string1" type="xs:string" minOccurs="0"/>
       <xs:element name="string2" type="xs:string" minOccurs="0"/>
   </xs:sequence>

<xs:complexType name="testResponse">
   <xs:sequence>
       <xs:element name="rstring" type="xs:string" minOccurs="0"/>
   </xs:sequence>

In above example , you can spot the difference. This is the only difference they implicate in wsdl. Note: Above example is explained for Document type soap binding, in RPC, no xsd is involved so RPC.Bare is applicable only.

like image 133
kingAm Avatar answered Nov 10 '22 22:11

kingAm


The document/literal wrapped style is the best approach and is also the default. Wrapped document style with literal encoding has the following advantages:

  1. There is no type encoding info.

  2. Everything that appears in the soap:body is defined by the Schema, so you can easily validate the message.

  3. You have the method name in the soap message.

  4. Document/literal is WS-I compliant, but without the WS-I restriction that the SOAP.body should have only one Child. The wrapped pattern meets the WS-I restriction that the SOAP messages SOAP.body has only one Child.

But in few cases you might have to use another style. If you have overloaded operations, you cannot use the document/literal wrapped style. WSDL allows overloaded operations, but when you add the wrapped pattern to WSDL, you require an element to have the same name as the operation, and you cannot have two elements with the same name in XML. So you must use the document/literal, non-wrapped style or one of the RPC styles.

Source: Which style of WSDL should I use?

like image 39
lupchiazoem Avatar answered Nov 10 '22 22:11

lupchiazoem