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

SOAP::Header with WSDL ends up in SOAP-Env:Body not SOAP-Env:Header

Expand Messages
  • ximon_18
    Hi, I need to talk to this service: https://storm5.login.skylist.net/services/SoapRequestProcessor?wsdl The getVersion() method does not require authentication
    Message 1 of 1 , Jul 30 6:24 AM
    • 0 Attachment
      Hi,

      I need to talk to this service:
      https://storm5.login.skylist.net/services/SoapRequestProcessor?wsdl

      The getVersion() method does not require authentication and I can
      invoke it fine. The getDetailedMailingReport() does require
      authentication and according to the API manual this must be done by
      providing username and password in the SOAP header.

      If I do this:

      use SOAP::Lite +'trace';
      my $service = SOAP::Lite->service('URL_GIVEN_ABOVE');
      $service->getVersion();

      I get back a version string. Cool. If I do this it still works:

      use SOAP::Lite +'trace';
      my $service = SOAP::Lite->service('URL_GIVEN_ABOVE');
      my $header = SOAP::Header->new(name => 'authInfo', value =>
      {username=>$user, password=>$pass});
      $service->getVersion($header);

      And interestingly with 'trace' enabled I can see that the raw XML
      POSTed looks like this:

      <?xml version="1.0" encoding="UTF-8"?>
      <SOAP-ENV:Envelope xmlns:namesp1="http://xml.apache.org/xml-soap"
      xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
      xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:xsd="http://www.w3.org/1999/XMLSchema"
      SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
      <SOAP-ENV:Header>
      <authInfo xsi:type="namesp1:SOAPStruct">
      <password xsi:type="xsd:string">PASSWORD</password>
      <username xsi:type="xsd:string">USERNAME</username>
      </authInfo>
      </SOAP-ENV:Header>
      <SOAP-ENV:Body>
      <namesp2:getVersion
      xmlns:namesp2="http://services.web.stormpost.skylist.com"/>
      </SOAP-ENV:Body>
      </SOAP-ENV:Envelope>

      Note that there is a SOAP-Env:Header block.

      However, if I do this:

      use SOAP::Lite +'trace';
      my $service = SOAP::Lite->service('URL_GIVEN_ABOVE');
      my $header = SOAP::Header->new(name => 'authInfo', value =>
      {username=>$user, password=>$pass});
      $service->getDetailedMailingReport($header, 74144);

      The XML sent changes, the SOAP-ENV:Header block disappears and the
      username/password move into the SOAP-ENV:Body block. How can I fix
      this? The XML generated looks like this:

      <?xml version="1.0" encoding="UTF-8"?>
      <SOAP-ENV:Envelope
      xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
      xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:xsd="http://www.w3.org/1999/XMLSchema"
      xmlns:namesp2="http://xml.apache.org/xml-soap"
      SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
      <SOAP-ENV:Body>
      <namesp1:getDetailedMailingReport
      xmlns:namesp1="http://services.web.stormpost.skylist.com">
      <authInfo xsi:type="namesp2:SOAPStruct">
      <password xsi:type="xsd:string">PASSWORD</password>
      <username xsi:type="xsd:string">USERNAME</username>
      </authInfo>
      <c-gensym4 xsi:type="xsd:int">74144</c-gensym4>
      </namesp1:getDetailedMailingReport>
      </SOAP-ENV:Body>
      </SOAP-ENV:Envelope>

      The reason I'm doing this is because I get this error from the service
      I am talking to:

      <?xml version="1.0" encoding="utf-8"?>
      <soapenv:Envelope
      xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <soapenv:Body>
      <soapenv:Fault>
      <faultcode>soapenv:Server.generalException</faultcode>
      <faultstring>An internal error has occured.; nested exception is:
      This service method requires user authentication.
      Username/password is required.</faultstring>
      <detail>
      <ns1:hostname
      xmlns:ns1="http://xml.apache.org/axis/">storm5</ns1:hostname>
      </detail>
      </soapenv:Fault>
      </soapenv:Body>
      </soapenv:Envelope>
    Your message has been successfully submitted and would be delivered to recipients shortly.