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

I'm trying to do a SOAP call to http://www.webservicex.net/ConvertSpeed.asmx

My code as follows :

use SOAP::Lite; my $client = SOAP::Lite->new; $client = $client->service( "http://www.webservicex.net/ConvertSpee +d.asmx?wsdl" ); my $soapResp = $client->call( "ConvertSpeed", 100, "kilometersPerhour" +, "milesPerhour" ); if ( $soapResp->fault ) { print $soapResp->faultstring; } else { print $soapResp->result; }

This gives me the following error :

A service address has not been specified either by using SOAP::Lite->proxy() or a service description)

As far as I understand it the service address is obtained from the WSDL. I did however try using
$client->proxy("http://www.webservicex.net/ConvertSpeed.asmx"), but then I got the following error :

Server did not recognize the value of HTTP Header SOAPAction: #ConvertSpeed

Since the WSDL is supposed to handle the service address I removed the $client->proxy() bit and tried
other stuff. I have been struggling with this for 2 days now so I can't recall everything I tried, but
I did reduce method chaining a lot from my initial code to what I posted above. I also tried using
$client->ConvertSpeed(100, "kilometersPerhour", "milesPerhour") directly as I have seen it done this way
elsewhere, but it seems to not return anything.

This is running on Perl 5.10 and version 0.714 of SOAP::Lite.
I have also tested on Perl 5.22.1 and version 1.19.

I have also confirmed that this SOAP call works in other languages.

Replies are listed 'Best First'.
Re: Problem with SOAP call using SOAP::Lite and wsdl
by rahed (Scribe) on Jan 19, 2018 at 10:54 UTC
    Don't use a service method when the service is complex. According to wsdl the code could be:
    $client = SOAP::Lite->new( uri => 'http://www.webserviceX.NET/', proxy => 'http://www.webservicex.net/ConvertSpeed.asmx', ); $client->on_action(sub {"http://www.webserviceX.NET/ConvertSpeed"}); $client->autotype(0); $sheader = SOAP::Header->new(''); $sheader->type(xml => ''); $client->ns('http://www.webserviceX.NET/','web'); $client->envprefix('soapenv'); push @request, SOAP::Data->name(speed => 100)->prefix('web'); push @request, SOAP::Data->name(FromUnit => 'kilometersPerhour')->pref +ix('web'); push @request, SOAP::Data->name(ToUnit => 'milesPerhour')->prefix('web +'); $soapResp = $client->ConvertSpeed($sheader,@request); print $soapResp->result,"\n";
      Thank you for the reply, this does work my side too.

      Any reason the WSDL doesn't work for complex services?
        To my mind SOAP::Lite wasnt' designed to build a soap structure directly from a wsdl file. For that there's a better module, XML::Compile::WSDL11.