Note that there are some explanatory texts on larger screens.

plurals
  1. POCan client generated from WSDLs produce requests that exclude optional header elements?
    text
    copied!<p>I am creating a client using jax-ws generated code. The WSDLs used specify a number of header elements like so, within the binding element:</p> <pre><code>&lt;wsdl:operation name="operation"&gt; &lt;wsoap12:operation soapActionRequired="false" style="document"/&gt; &lt;wsdl:input&gt; &lt;wsoap12:header message="tns:InMsg" part="header1" use="literal"/&gt; &lt;wsoap12:header message="tns:InMsg" part="header2" use="literal"/&gt; &lt;wsoap12:header message="tns:InMsg" part="header3" use="literal"/&gt; &lt;wsoap12:header message="tns:InMsg" part="header4" use="literal"/&gt; &lt;wsoap12:header message="tns:InMsg" part="header5" use="literal"/&gt; &lt;wsoap12:body parts="request" use="literal"/&gt; &lt;/wsdl:input&gt; &lt;wsdl:output&gt; &lt;wsoap12:header message="tns:OutMsg" part="header1" use="literal"/&gt; &lt;wsoap12:header message="tns:OutMsg" part="header2" use="literal"/&gt; &lt;wsoap12:body parts="response" use="literal"/&gt; &lt;/wsdl:output&gt; &lt;wsdl:fault name="standardError"&gt; &lt;wsoap12:fault name="standardError" use="literal"/&gt; &lt;/wsdl:fault&gt; &lt;/wsdl:operation&gt; </code></pre> <p>My question centres around, for the sake of argument, <code>header5</code>. According to specifications I am working from, this is an optional value. As such, I generate my client using JAX-WS and either have to pass null (to simulate a value not specified) or valid header value as the operation parameter for the <code>header5</code> value to be added in to the request. This would subsequently create a <code>&lt;header5&gt;</code> element with no child elements. The problem I then encounter is that the consuming service appears to do some sort of validation on that header element and determines it to be malformed as it would normally contain a few different child elements.</p> <p>As such, is there a way, using JAX-WS, to essentially meet this optional header requirement by excluding the header element altogther from the SOAP request? There seems to be some contention among my colleagues as to whether this would violate the contract defined by the WSDL and cause the service to return an error. There is a claim that .Net clients allow you to exclude the header from the request, simply by specifiying it as null.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload