Loading ...
Sorry, an error occurred while loading the content.

Question on WSDL with soap header

Expand Messages
  • Weidong Wang
    I am trying to write a WSDL for a soap interface which needs soap header elements. The only example I can find is the one in the WSDL 1.1 spec. Either I got
    Message 1 of 1 , Jan 4, 2002
    • 0 Attachment
      I am trying to write a WSDL for a soap interface which needs soap header elements. The only example I can find is the one in the WSDL 1.1 spec. Either I got the wsdl written wrong, or I made the call in the wrong way (could not find an example showing how to make a call with header, so I used the same way that I did before, with SOAP::Header->name()->uri() way), the header field was not added and the server kept rejecting it.
       
      Thanks.
       
       
      Here is what the SOAP request and response should look like:
       
      <s:env ....>
        <s:header>
          <GTargetName>test</GTargetName>
        </s:header>
        <s:body>
          <GetAccountURL/>
        </s:body>
      </s:env>
       
      <s:env ...>
        <s:body>
          <GetAccountURLResponse>
            <AccountURL>account://test/abc</AccountURL>
          </GetAccountURLResponse>
        </s:body>
      </s:env>
       
      Here is the WSDL that I made:
       
      <?xml version="1.0"?>
      <definitions name="StockQuote"
                targetNamespace="http://example.com/stockquote.wsdl"
                xmlns:tns="http://example.com/stockquote.wsdl"
                xmlns:xsd1="http://example.com/stockquote.xsd"
                xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
                xmlns="http://schemas.xmlsoap.org/wsdl/">
       
          <message name="GetAccountURL">
              <part name="body" element="xsd1:GetAccountURL"/>
              <part name="GTargetName" element="xsd1:SubscriptionHeader"/>
          </message>
       
          <message name="GetAccountURLResponse">
              <part name="result" element="xsd1:GetAccountURLResult"/>
          </message>
       
          <portType name="StockQuotePortType">
              <operation name="GetAccountURL">
                 <input message="tns:GetAccountURL"/>
                 <output message="tns:GetAccountURLResponse"/>
              </operation>
          </portType>
       
          <binding name="StockQuoteSoap" type="tns:StockQuotePortType">
              <soap:binding style="document" transport="http://example.com/http"/>
              <operation name="GetAccountURL">
                 <soap:operation soapAction="http://example.org/GetAccountURL"/>
                 <input message="tns:GetAccountURL">
                     <soap:body parts="body" use="literal"/>
                     <soap:header message="tns:GetAccountURL" part="GTargetName" use="literal"/>
                 </input>
                 <output message="tns:GetAccountURLResponse">
                      <soap:body use="literal"/>
                 </output>
             </operation>
          </binding>
       
          <service name="StockQuoteService">
              <port name="StockQuotePort" binding="tns:StockQuoteSoap">
                 <soap:address location="http://wwrelay:8009/SOAP"/>
              </port>
          </service>
       
          <types>
              <schema targetNamespace="http://example.com/stockquote.xsd"
                     xmlns="http://www.w3.org/2000/10/XMLSchema">
                 <element name="GetAccountURL"/>
                 <element name="GetAccountURLResult" type="string"/>
                 <element name="SubscriptionHeader" type="string"/>
              </schema>
          </types>
      </definitions>
       
      And here is my Perl code to call it:
       
      #!perl -w
       
      use SOAP::Lite;
       
      # import interface
      my $soap = SOAP::Lite
          -> service('file:./gwdoc.wsdl');
      my $uri = 'urn:example.org';
      print $soap->GetAccountURL(
            SOAP::Header->name(GTargetName => 'test')->uri($uri)
            ), "\n";
    Your message has been successfully submitted and would be delivered to recipients shortly.