Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I mark a SOAP Header as optional in WSDL?

I have a wsdl with an optional header:

<s:element name="AuthIdentifier" type="tns:AuthIdentifier"/>
<s:complexType name="AuthIdentifier">
  <s:sequence>
    <s:element minOccurs="0" maxOccurs="1" name="identifier" type="s:string"/>
  </s:sequence>
  <s:anyAttribute/>
</s:complexType>

The client is using an integration software (tibco) to connect to my service and claims that the header is required, so he must send it with an empty value:

<Header.AuthIdentifier>
   <ns0:AuthIdentifier xmlns:ns0 = "http://www.tal.com/schemas"/>
</Header.AuthIdentifier>

How do I make it optional? So that he won't have to send the whole header at all? Is there a minOccurs or something like that? Or is it already optional as it is now?

like image 327
Tal Giladi Avatar asked Jan 21 '16 10:01

Tal Giladi


People also ask

Is header optional in SOAP?

The SOAP <Header> is an optional element in a SOAP message. It is used to pass application-related information that is to be processed by SOAP nodes along the message path. The immediate child elements of the <Header> element are called header blocks.

How do you define a header in WSDL?

You can populate a SOAP header in the following ways: Define the SOAP header in the WSDL definition as part of the SOAP binding. You indicate these headers by using a <soap:header> tag in the <wsdl:input> and <wsdl:output> elements in the WSDL file.

How do you add a header in WSDL?

You can add soap header information to method calls by decorating the methods in the proxy class generated from the wsdl with the SoapHeader attribute. For example wsdl.exe will generate client proxy class Reference. cs for the web service reference when you "Add Web Reference".


1 Answers

According to "Web Service Contract Design & Versioning" Thomas Erl et al (ISBN-13: 978-0-13-613517-3) Chapter 15.4, Defining SOAP Blocks in WSDL:

The WSDL 1.1 Specification is unclear about whether SOAP headers described in a WSDL document must be included by consumers or not. The WS-I Basic Profile made it mandatory for consumers to include them, but WDL 2.0 provides the choice as to whether consumers should be forced to include them or not. Page 472.

In WSDL 2.0 you can set the attribute wsdl:required="false" in the custom SOAP header block to indicate whether consumers must include this header block.

like image 146
Daniel James Bryars Avatar answered Sep 27 '22 21:09

Daniel James Bryars