获得;尚未指定服务地址…”;使用Perl SOAP::Lite时使用wsdl调用

获得;尚未指定服务地址…”;使用Perl SOAP::Lite时使用wsdl调用,perl,soap,wsdl,Perl,Soap,Wsdl,我正在尝试对http://www.webservicex.net/ConvertSpeed.asmx使用WSDL 我的代码如下 use SOAP::Lite; my $client = SOAP::Lite->new; $client = $client->service( "http://www.webservicex.net/ConvertSpeed.asmx?wsdl" ); my $soapResp = $client->call( "ConvertSpeed

我正在尝试对
http://www.webservicex.net/ConvertSpeed.asmx
使用WSDL

我的代码如下

use SOAP::Lite;

my $client = SOAP::Lite->new;
$client    = $client->service( "http://www.webservicex.net/ConvertSpeed.asmx?wsdl" );

my $soapResp = $client->call( "ConvertSpeed", 100, "kilometersPerhour", "milesPerhour" );

if ( $soapResp->fault ) {
    print $soapResp->faultstring;
}
else {
    print $soapResp->result;
}
这给了我以下的错误

未使用SOAP::Lite->proxy()或服务描述指定服务地址)

我相信WSDL应该提供服务地址,但在这里它似乎没有这样做

我已尝试将服务地址设置为
http://www.webservicex.net/ConvertSpeed.asmx
通过
$client->proxy(“http://www.webservicex.net/ConvertSpeed.asmx“
$client->service()
之后,但这只会给我一个错误,告诉我:

Server did not recognize the value of HTTP header SOAPAction: #ConvertSpeed
我假设WSDL应该提供服务地址,因此省略了
$client->proxy()
位并尝试了其他方法

这包括从不同的链接方法到尽可能少的链接(上面的代码),再到更改调用的方式

我试过了

似乎什么也没有回报

这是在Perl5.10和0.714版的SOAP::Lite上运行的

我不确定还可以尝试什么,但我已经确认相同的SOAP调用可以从Python中工作(请参见编辑)

编辑:

来自zeep导入客户端的

客户机=客户机('http://www.webservicex.net/ConvertSpeed.asmx?wsdl')
结果=client.service.ConvertSpeed(100,'公里/小时','英里/小时')
打印(结果)

我也把这个问题发到了PerlMonks,因为它在这里似乎做得不好。根据我得到的答案,
SOAP::Lite
不适合使用WSDL的复杂服务。相反,应该使用
uri()
proxy()
方法指定所有内容。如果要使用WSDL,则要查看的模块是
XML::Compile::WSDL11

答案使用
SOAP::Lite
为调用提供工作代码,而不使用WSDL,如下所示:

$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')->prefix('web');
push @request, SOAP::Data->name(ToUnit => 'milesPerhour')->prefix('web');

$soapResp = $client->ConvertSpeed($sheader,@request);

print $soapResp->result,"\n";

如果我得到一个使用
XML::Compile::WSDL11
的工作示例,我将在这里发布它。因为我不确定我是否会很快研究它,我决定至少发布这篇文章,因为问题更集中于使用带有
SOAP::Lite

的WSDL,服务地址与代理地址不同。您正在使用的WSDL URL似乎是有效的,但是库声称它没有服务描述。如果您有可用的Python代码,请编辑您的问题以显示出来。@Borodin请参阅文章中的编辑。这就是使用Python3。
$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')->prefix('web');
push @request, SOAP::Data->name(ToUnit => 'milesPerhour')->prefix('web');

$soapResp = $client->ConvertSpeed($sheader,@request);

print $soapResp->result,"\n";