I've started to use document-style web-services
recently.
I've learned that in this way we can have only one part
("parameter") for input/output message, which can contain all data.
But now I've read about Holders
, which, according to this link, is used to return multiple parameters.
Now I wonder, why should I use Holders, if I can use the document-style response, which can contain everything?
Additional info I found here still left me uncertain.
I've started to use document-style web-services recently. I've learned that in this way we can have only one part("parameter") for input/output message, which can contain all data.
You have to distinguish between document/literal bare (or unwrapped)
and document/literal wrapped
. While for the latter one your statement is true, it is false for the primer one. In relation to an IBM guide for the specific type encodings you will see that document/literal bare
can specify multiple part
elements:
<types>
<schema>
<element name="xElement" type="xsd:int"/>
<element name="yElement" type="xsd:float"/>
</schema>
</types>
<message name="myMethodRequest">
<part name="x" element="xElement"/>
<part name="y" element="yElement"/>
</message>
<message name="empty"/>
<portType name="PT">
<operation name="myMethod">
<input message="myMethodRequest"/>
<output message="empty"/>
</operation>
</portType>
which results in a SOAP message:
<soap:envelope>
<soap:body>
<xElement>5</xElement>
<yElement>5.0</yElement>
</soap:body>
</soap:envelope>
One of the main disadvantages however is that you lose information on the method invoked - besides not being WS-I compliant. Therefore document/literal wrapped
is used (which is the recommended binding-style) to bypass the limitations of bare
binding-styles.
Further note that document/literal wrapped
is not part of the actual WSDL spec per se:
In document/literal style of messaging, there exists a pattern which is known as wrapped-document/literal. This is just a pattern, and is not a part of WSDL specification. This pattern has a mention in JSR 224 (JAX-WS: Java API for XML based web services). (Source)
@Edit: Due to your origin question and your comment regarding why you might use Handler
s:
WSDL specifies IN
, OUT
and INOUT
parameters. While the first two parameters are pretty easy to understand, the latter is a bit more tricky, as the parameter sent to the service should be returned with the modified state.
However, Java is pass by value and not pass by reference and to enable an update of the same parameter, similar to the way pass by reference works, Handler
s can be used to "fake" a WSDL conform processing for OUT
or INOUT
parameters.
For a simple code example and probably better explanation please have a look at a very similar question and its answer