这里http://code.google.com/p/delcampe-api-client/wiki/Info#Perl是Perl中delcampe-api-client的代码示例。显然,有一个语法错误,运行我得到的代码:
syntax error at test.pl line 9, near "-> service"
Bareword "SOAP::Lite" not allowed while "strict subs" in use at test.pl line 8.
Execution of test.pl aborted due to compilation errors.
如果我改变代码对我来说更有意义,就像这样:
#!/usr/bin/perl
use SOAP::Lite;
use SOAP::WSDL;
use strict;
use warnings;
my $service = new SOAP::Lite;
print $service
->uri('http://api.delcampe.net/soap.php?wsdl')
->getServerTime()
->result;
我得到了:
A service address has not been specified either by using SOAP::Lite->proxy() or a service description)
这段代码有什么问题?什么代理?服务说明?
[如果你认为,我没有使用过SOAP的经验,那你肯定是对的。不过,如何让这个小例子起作用。 PHP示例运行良好,但不是Perl的。 ]
答案 0 :(得分:4)
如果我是你,我会尝试“精美文档”。但这应该有效:
#!/usr/bin/perl
use SOAP::Lite;
use SOAP::WSDL;
use strict;
use warnings;
my $service = SOAP::Lite->service('http://api.delcampe.net/soap.php?wsdl');
print $service->getServerTime()->result;
修改强>
可以在http://guide.soaplite.com/找到文档 - 也可以从命令行中找到perldoc SOAP :: Lite。
网站上的示例(上图)似乎不能用于多个计数:但是,这个示例已经过测试并可在我的计算机上运行:
#!/usr/bin/perl
use SOAP::Lite;
use strict;
use warnings;
my $service = SOAP::Lite->service('http://api.delcampe.net/soap.php?wsdl');
print $service->getServerTime();