If you are using the native System.Web.Services namespace to consume a web service using SOAP, and you get the following error:
System.Exception: An operation can have only one in or out header of a given type. <Header> conflicts with another header field of the same type and direction.
Don't necessarily think that the services WSDL is broken. Check your WSDL and see if it repeats the same header part for the input and output sections (see sample below) using the ws-addressing (wsa) namespace.
<!-- Message information header blocks -->
<xs:element name="MessageID" type="wsa:AttributedURI"/>
<xs:element name="RelatesTo" type="wsa:Relationship"/>
<xs:element name="To" type="wsa:AttributedURI"/>
<xs:element name="Action" type="wsa:AttributedURI"/>
<xs:element name="From" type="wsa:EndpointReferenceType"/>
<xs:element name="ReplyTo" type="wsa:EndpointReferenceType"/>
<xs:element name="FaultTo" type="wsa:EndpointReferenceType"/>
<xs:complexType name="Relationship"><operation name="<OperationName>">
<soap:operation soapAction="<Action>"/><input>
<soap:body parts="messagePart" use="literal"/>
<soap:header message="tns:Headers" part="From" use="literal"/>
<soap:header message="tns:Headers" part="To" use="literal"/>
<soap:header message="tns:Headers" part="Action" use="literal"/>
<soap:header message="tns:Headers" part="MessageID" use="literal"/>
<soap:header message="tns:Headers" part="Security" use="literal"/>
</input><output>
<soap:body parts="messagePart" use="literal"/>
<soap:header message="tns:Headers" part="From" use="literal"/>
<soap:header message="tns:Headers" part="To" use="literal"/>
<soap:header message="tns:Headers" part="Action" use="literal"/>
<soap:header message="tns:Headers" part="MessageID" use="literal"/>
<soap:header message="tns:Headers" part="RelatesTo" use="literal"/>
</output><fault name="SoapFault">
<soap:fault name="SoapFault" use="literal"/>
</fault>
</operation>
You'll need to upgrade your code to use the Web Services Enhancements v3.0 from Microsoft (if you are using .NET 2.0 that is). You'll want to regenerate your Web Service Proxy using the WseWsdl3 tool that the enhancements install. Remember that you'll need this enhancement installed on the client that is utilising the Web Service as well when you come to deploy your solution.
No comments:
Post a Comment