我写的基于Delcampe API的soap-client。简单的方法工作正常,但功能需要复杂的数据给我一个错误消息,如“你必须发送项目的数据!”。基于PHP示例here我认为,该数据应该是哈希或hashref,但都给我前面提到的错误。Perl:我应该向delcampe API提供什么样的数据?
示例脚本使用:
use 5.010;
use SOAP::Lite;
use SOAP::WSDL;
use strict;
use warnings;
use Data::Dumper;
my $API_key = 'xyz';
my $service = SOAP::Lite->service('http://api.delcampe.net/soap.php?wsdl');
my $return = $service->authenticateUser($API_key);
if ($return->{status}) {
my $key = $return->{data};
my %data = (description => 'updated description');
my $response = $service->updateItem($key, 123456, \%data);
if ($response->{status}) {
say Dumper $response->{data};
} else {
say $response->{errorMsg};
}
} else {
say "no: " . $return->{status};
}
所以,我应该使用的,而不是%data
什么样的数据结构,或者我怎么能调试SOAP信封,这是作为请求? (基于例如PHP代码工作正常)
ADDITION
use SOAP::Lite qw(trace);
与IGOT SOAP信封太:
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://api.delcampe.net/soap.php">
<soap:Body>
<tns:updateItem>
<token xsi:type="xsd:string">secret_one</token>
<id_item xsi:type="xsd:int">123456</id_item>
<arrData xsi:nil="true" xsi:type="soap-enc:Array" />
</tns:updateItem>
</soap:Body>
</soap:Envelope>
如上所示,没有发送的数据的比特。我也尝试数据作为字符串,数组和阵列参考。也许这是SOAP::Lite
的错误?
你有没有尝试在'%data'中包含'personal_reference'和'title'键? PHP示例设置了全部3个,并且文档不清楚它们是否可选。 – cjm 2012-02-17 22:40:11
@cjm,我试着改变只有PHP的描述,它的工作。 – 2012-02-17 23:01:39
适用标准的HTTP调试技术。使用Wireshark比较请求/响应对。 – daxim 2012-02-18 11:27:25