Perl中的SOAP客户端
我试着用Perl和SOAP::Lite“交谈” 在PHP中,其简单程度如下:Perl中的SOAP客户端,perl,soap,wsdl,Perl,Soap,Wsdl,我试着用Perl和SOAP::Lite“交谈” 在PHP中,其简单程度如下: <? $client = new SoapClient('https://webapi.allegro.pl.webapisandbox.pl/service.php?wsdl'); $results = $client->doQueryAllSysStatus(array( 'countryId' => 1, 'webapiKey' => 'XXXXXX' )); header
<?
$client = new SoapClient('https://webapi.allegro.pl.webapisandbox.pl/service.php?wsdl');
$results = $client->doQueryAllSysStatus(array(
'countryId' => 1,
'webapiKey' => 'XXXXXX'
));
header('Content-type: text/plain');
var_dump($results);
?>
$som->result
为空
还审判了:
use SOAP::Lite;
my $soap = SOAP::Lite->service('https://webapi.allegro.pl.webapisandbox.pl/service.php?wsdl');
my $r = $soap->doQueryAllSysStatus(1, 'xxxxxx');
print $r, "\n";
。。。并在打印中使用了未初始化值$r
任何帮助都将不胜感激
更新#1:
PHP代码输出以下内容:
object(stdClass)#2 (1) {
["sysCountryStatus"]=>
object(stdClass)#3 (1) {
["item"]=>
object(stdClass)#4 (8) {
["countryId"]=>
int(1)
["programVersion"]=>
string(3) "1.0"
["catsVersion"]=>
string(6) "1.4.94"
["apiVersion"]=>
string(3) "1.0"
["attribVersion"]=>
string(3) "1.0"
["formSellVersion"]=>
string(7) "1.11.91"
["siteVersion"]=>
string(3) "1.0"
["verKey"]=>
int(1505223106)
}
}
}
我没有web api密钥,因此无法进行完全测试,但类似这样的东西呢
#!/usr/bin/perl
use warnings;
use strict;
use SOAP::Lite;
my $soap = SOAP::Lite->new( proxy => 'https://webapi.allegro.pl.webapisandbox.pl/service.php?wsdl');
my $country = 1;
my $api = 'XXXXX';
my $r = $soap->doQueryAllSysStatus($country,$api);
print $r->result, "\n";
---更新---
我找到了一个有效的解决方案,所以对于任何好奇的人来说,它就是 我放弃了
SOAP::Lite
,在HTTP::Tiny
的帮助下使用了XML::Compile::*
模块
守则:
use Data::Printer;
use HTTP::Tiny;
use XML::Compile::SOAP11;
use XML::Compile::WSDL11;
use XML::Compile::Transport::SOAPHTTP;
my $wsdlXml = HTTP::Tiny->new->get('https://....')->{content};
my $wsdl = XML::Compile::WSDL11->new($wsdlXml);
my $response = $wsdl->compileCall('doQueryAllSysStatus')->(
countryId => 1,
webapiKey => 'xxxxxx'
);
p $response;
打印出:
\ {
parameters {
sysCountryStatus {
item [
[0] {
apiVersion 1.0,
attribVersion 1.0,
catsVersion "1.4.94",
countryId 1,
formSellVersion "1.11.91",
programVersion 1.0,
siteVersion 1.0,
verKey 1505223106
}
]
}
}
}
耶!;) 与我的示例相同:结果为空:(预期的输出是什么?添加在上面原始邮政编码底部的PHP输出可能会打印出所有内容,但看起来它正在获取数据是的,但我不知道如何获取重要内容(结果为
doQueryAllSysStatus
)…很好,很高兴你能让它工作。似乎出于某种原因,SOAP::Lite应该工作,但猜不到
use Data::Printer;
use HTTP::Tiny;
use XML::Compile::SOAP11;
use XML::Compile::WSDL11;
use XML::Compile::Transport::SOAPHTTP;
my $wsdlXml = HTTP::Tiny->new->get('https://....')->{content};
my $wsdl = XML::Compile::WSDL11->new($wsdlXml);
my $response = $wsdl->compileCall('doQueryAllSysStatus')->(
countryId => 1,
webapiKey => 'xxxxxx'
);
p $response;
\ {
parameters {
sysCountryStatus {
item [
[0] {
apiVersion 1.0,
attribVersion 1.0,
catsVersion "1.4.94",
countryId 1,
formSellVersion "1.11.91",
programVersion 1.0,
siteVersion 1.0,
verKey 1505223106
}
]
}
}
}