我有一个带有可选标题的wsdl:
<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>
客户端正在使用集成软件(tibco)连接到我的服务,声称该头是必需的,所以他必须发送一个空值:
<Header.AuthIdentifier> <ns0:AuthIdentifier xmlns:ns0 = "http://www.tal.com/schemas"/> </Header.AuthIdentifier>
如何使其可选?所以他根本不用发送整个标题?有没有minOccurs或类似的东西?还是现在已经是可选的了?
解决方法
根据“Web服务合同设计与版本控制”Thomas Erl等(ISBN-13:978-0-13-613517-3)第15.4节,在WSDL中定义SOAP块:
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.
在WSDL 2.0中,您可以在自定义SOAP标头块中设置属性wsdl:required =“false”,以指示消费者是否必须包含此标头块。