3

I'm implementing a SOAP-based web-service and have got WS-Addressing working. However, I can't see how to get the WSDL to publish what the client should use as the value of the wsa:To element.

I have used the snippet below in my WSDL, and used SOAP-UI to generate a request. It seems that SOAP-UI recognises that wsa:action should be set to "http://myco.com/myOperation", although it doesn't add this header automatically. I have to select the "Add WS-A Headers" menu option.

My problem is that it doesn't add a wsa:To header. Can anyone tell me how I amend my WSDL to tell clients that a wsa:To is required and that its value should be "http://myco.com/cap/services/v1"?

Thanks

<wsdl:portType name="MyPortType">
    <wsdl:operation name="MyOperation">
        <wsdl:input message="tns:MyRequestMessage" name="Request"
                    wsaw:Action="http://myco.com/myOperation"/>
        <wsdl:output message="tns:MyResponseMessage" name="Response"/>
    </wsdl:operation>
</wsdl:portType>

<wsdl:binding name="MyBinding" type="tns:MyPortType">

    <soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsaw:UsingAddressing wsdl:required="true"/>
    <wsdl:operation name="MyOperation">
        <soap:operation soapAction="" style="document"/>
        <wsdl:input>
            <soap:body use="literal"/>
        </wsdl:input>
        <wsdl:output>
            <soap:body use="literal"/>
        </wsdl:output>
    </wsdl:operation>
</wsdl:binding>


<wsdl:service name="MyService">
    <wsdl:port binding="tns:MyBinding" name="MyPort">
        <soap:address location="http://myco.com/services"/>
        <wsa:Address>http://myco.com/cap/services/v1</wsa:Address>
    </wsdl:port>
</wsdl:service>
elgaz
  • 121
  • 2
  • 9

1 Answers1

2

To achieve this I defined the namespace for ws addressing 2005 version

<xs:schema ... xmlns:wsa5="http://www.w3.org/2005/08/addressing">
 ....
</xs:schema>

a message type

<wsdl:message name="wsaHeader">
        <wsdl:part name="MessageID" element="wsa5:MessageID" />
        <wsdl:part name="RelatesTo" element="wsa5:RelatesTo" />
        <wsdl:part name="From" element="wsa5:From" />
        <wsdl:part name="ReplyTo" element="wsa5:ReplyTo" />
        <wsdl:part name="FaultTo" element="wsa5:FaultTo" />
        <wsdl:part name="To" element="wsa5:To" />
        <wsdl:part name="Action" element="wsa5:Action" />
</wsdl:message>

Then in my input and output I placed the following tags.

<wsdl:input>
    <soap:header use="literal" message="tns:wsaHeader" part="Action"/>
    <soap:header use="literal" message="tns:wsaHeader" part="To"/>
    <soap:header use="literal" message="tns:wsaHeader" part="FaultTo"/>
    <soap:header use="literal" message="tns:wsaHeader" part="ReplyTo"/>
    <soap:header use="literal" message="tns:wsaHeader" part="From"/>
    <soap:header use="literal" message="tns:wsaHeader" part="RelatesTo"/>
    <soap:header use="literal" message="tns:wsaHeader" part="MessageID"/>
    <soap:body use="literal" />
  </wsdl:input>
  <wsdl:output>
    <soap:header use="literal" message="tns:wsaHeader" part="Action"/>
    <soap:header use="literal" message="tns:wsaHeader" part="To"/>
    <soap:header use="literal" message="tns:wsaHeader" part="FaultTo"/>
    <soap:header use="literal" message="tns:wsaHeader" part="ReplyTo"/>
    <soap:header use="literal" message="tns:wsaHeader" part="From"/>
    <soap:header use="literal" message="tns:wsaHeader" part="RelatesTo"/>
    <soap:header use="literal" message="tns:wsaHeader" part="MessageID"/>
    <soap:body use="literal" />
  </wsdl:output> 

You may only need to add the To tag for your purposes.

Paul Rooney
  • 20,879
  • 9
  • 40
  • 61
  • Paul I am trying to figure out what the "tns" is for in message="tsn:wsaHeader". I didn't see you set a namespace and I don't think that is set in the WS-Addressing definition and you define the message as "wsaHeader" so it seems like you should just refer to it as that in your input and output items. – user461051 Aug 07 '15 at 18:41
  • I saw an example here http://www.w3.org/Submission/ws-addressing/ that uses tns so I am thinking it means targetNamespace but not sure why you would have to explicitly call that out. – user461051 Aug 07 '15 at 19:58
  • Hi sorry for the delayed response. My knowledge of WSDL is quite limited, so unfortunately I cant give you an authoritative answer. My understanding was that yes `tns` and `targetNamespace` are the same thing and that its generally used to refer to the namespace you set up to refer to all your own types, ports, bindings etc. There are probably much simpler and more maintainable ways to do it than my answer, but as this resolved the issue for me I thought I'd post it. Please post another answer if you find a better way. – Paul Rooney Aug 12 '15 at 00:36