equick has asked for the wisdom of the Perl Monks concerning the following question:

Hi

I am trying to call a webservice over https using SOAP::Lite with the following code:

#!/usr/bin/perl use SOAP::Lite +trace ; use Data::Dumper; my $soap = SOAP::Lite ->proxy('https://certificatemanager.comodo.com:443/ws/EPKIManagerS +SL') ->uri('https://certificatemanager.comodo.com:443/ws/EPKIManagerSSL +'); my $method = SOAP::Data->name('getWebServiceInfo'); if($response->fault){ print $response->faultcode, " ", $response->faultstring, "\n"; die 'Terminating program'; }else{ my @results=@{$response->result}; print Dumper @results; }
This creates a soap request header like this:
<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" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <SOAP-ENV:Body> <getWebServiceInfo/> </SOAP-ENV:Body> </SOAP-ENV:Envelope>

but that fails with the message:

<faultstring>Cannot find dispatch method for {}getWebServiceInfo</faul +tstring>
I tested the service in soapUI and that worked fine with the following request header:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envel +ope/" xmlns:ssl="http://ssl.ws.epki.comodo.com/"> <soapenv:Header/> <soapenv:Body> <ssl:getWebServiceInfo/> </soapenv:Body> </soapenv:Envelope>

The issue I found was the absence of ssl: before the method call in the request header. Does anyone know how to fix this?

Thanks for any help

Ed.

Replies are listed 'Best First'.
Re: soap::lite request header
by charlesboyo (Beadle) on Aug 11, 2011 at 12:16 UTC
    Try setting the namespace uri with the 'ssl' prefix i.e.
    $soap->ns("http://ssl.ws.epki.comodo.com/", 'ssl');

      Thanks, unfortunately it didn't work.

      <?xml version="1.0" encoding="UTF-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" x +mlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="h +ttp://www.w3.org/2001/XMLSchema" soap:encodingStyle="http://schemas.x +mlsoap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.org/soa +p/envelope/" xmlns:ssl="http://ssl.ws.epki.comodo.com/"> <soap:Body><getWebServiceInfo xsi:nil="true" /></soap:Body></soap:Enve +lope> SOAP::Transport::HTTP::Client::send_receive: HTTP::Response=HASH(0x13a +c35d0) SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 500 Internal Ser +ver Error
        I got this to work, is this too much of a hack? Update: I am quite sure it is the correct thing to do. See below.
        $soap->ns("http://ssl.ws.epki.comodo.com/", 'ssl'); my $method = SOAP::Data->name('ssl:getWebServiceInfo');
        POST https://certificatemanager.comodo.com:443/ws/EPKIManagerSSL HTTP/ +1.1 ... SOAPAction: "http://ssl.ws.epki.comodo.com/#getWebServiceInfo" <?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:xsi="http:/ +/www.w3.org/2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xm +lsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema +" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmln +s:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ssl="http:// +ssl.ws.epki.comodo.com/"><soap:Body><ssl:getWebServiceInfo xsi:nil="t +rue" /></soap:Body></soap:Envelope> HTTP/1.1 200 OK Connection: close Date: Thu, 11 Aug 2011 13:28:38 GMT Server: Apache-Coyote/1.1 Content-Type: text/xml;charset=utf-8 ... <?xml version="1.0" ?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/ +soap/envelope/"><S:Body><ns2:getWebServiceInfoResponse xmlns:ns2="htt +p://ssl.ws.epki.comodo.com/"><return>Comodo Certificate Manager. SSL +Web Service. Version 1.1.</return></ns2:getWebServiceInfoResponse></S +:Body></S:Envelope>