问题
My WebService (compilant with SOAP 1.1 specification) uses its own type of header MyHeader defined within the xsd as follows:
<xs:complexType name="MyHeader">
<xs:sequence>
<xs:element name="MyElement1" type="xs:string"></xs:element>
<xs:element name="MyElement2" type="xs:string"></xs:element>
</xs:sequence>
</xs:complexType>
Unfortunately SAOP message generated "by AXIS 1.4 framework" has MyHeader element containing mustUnderstand="0" attribute:
<ns:MyHeader soapenv:mustUnderstand="0" xmlns:ns="http://....">
<ns:MyElement1>XXX</ns:MyElement1>
<ns:MyElement2>YYY</ns:MyElement2>
</ns:MyHeader>
According to specification SOAP mustUnderstand can be added to each header. However, it seems to me that the so-defined elements MyHeader can not contain this attribute, because the resulting XML is incompatible with the XML specification - it does not valide against XML rules of cvc-complex-type.
Is it allowed to add mustUnderstand attribute to this header instance? Does AXIS framework 1.4 works properly?
回答1:
To keep a long story short, please search for "removing mustUnderstand attribute from headers" and that should get you the solution; by default, this header shouldn't be added; if you have a need to actually use it, then I would modify your schema for the header part to include these SOAP attributes; if you want to see an example, please take a look at WS-I Claim schema (remove use="prohibited").
来源:https://stackoverflow.com/questions/9516053/custom-soap-1-1-header-and-mustunderstand-attribute