可能的SOAP版本不匹配:信封命名空间http://schemas.xmlsoap.org/soap/envelope/是意外的.期待http://www.w3.org/2003/05/soap-envelope.
这是因为库使用SOAP 1.1命名空间发送SOAP信封,服务器需要SOAP 1.2.
但我无法提出解决方案,我已经尝试明确设置$soap-> soapversion(‘1.2’);在SOAP :: Lite对象中但这仅影响响应消息中收到的Envelope,而不影响客户端发送的Envelope.
服务器正在运行ASP.net,似乎不想接受SOAP 1.1版消息.
默认情况下查询soapversion()方法它会返回版本1.1,当我将其更改为1.2时,它返回1.2但在内部它显然忽略了这一点.
WSDL似乎没有正确定义xmlns:soap或xmlns:soap12,但SOAP :: Lite也没有使用这些命名空间.我会提供一个链接,但我不允许在这里发布两个以上的链接.
我也试过使用SOAP :: Lite的service()方法但是没有任何区别.
这是我正在使用的代码:
#!/usr/bin/perl -w use strict; use SOAP::Lite; use Data::Dumper; ### API Info my $reseller = 'Removed'; my $username = 'Removed'; my $password = 'Removed'; my $soap = SOAP::Lite->new(proxy => 'https://sandbox.domainbox.net/'); $soap->default_ns('https://sandbox.domainbox.net/'); $soap->soapversion('1.2'); my $header = SOAP::Header->new->attr({xmlns => 'https://sandbox.domainbox.net/'}); my $body = SOAP::Data->name('CheckDomainAvailability' => \SOAP::Data->value( SOAP::Data->name('AuthenticationParameters' => \SOAP::Data->value( SOAP::Data->name('Reseller' => $reseller), SOAP::Data->name('Username' => $username), SOAP::Data->name('Password' => $password), ) ) ) ); $soap->on_action( sub { "https://sandbox.domainbox.net/" }); my $som = $soap->call('', $header, $body ); die $som->faultstring if ($som->fault); print $som->result, "\n"; #print Dumper($som);
额外:
无论类中的soapversion设置如何,信封中的xmlns:soap属性都设置为http://schemas.xmlsoap.org/soap/envelope.我认为它是Perl模块中的一个错误,或者是导致它的WSDL的一些奇怪的东西.这是WSDL:http://sandbox.domainbox.net/?WSDL
XML请求消息:
<?xml version="1.0" encoding="UTF-8"?><Envelope soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org /2001/XMLSchema-instance"><Header><c-gensym3 xmlns="https://sandbox.domainbox.net/" /></Header><Body><DomainboxAPI xmlns="https://sandbox.domainbox.net/"><CheckDomainAvailability> <AuthenticationParameters><Reseller xsi:type="xsd:string">Removed</Reseller><Username xsi:type="xsd:string">Removed</Username><Password xsi:type="xsd:string">Removed</Password></AuthenticationParameters> </CheckDomainAvailability></DomainboxAPI></Body></Envelope>
XML响应消息:
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Header> <soap12:Upgrade xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> <soap12:SupportedEnvelope qname="soap12:Envelope" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"/></soap12:Upgrade> </soap:Header><soap:Body><soap:Fault><soap:Code> <soap:Value>soap:VersionMismatch</soap:Value></soap:Code><soap:Reason> <soap:Text xml:lang="en">Possible SOAP version mismatch: Envelope namespace was unexpected. Expecting http://www.w3.org/2003/05/soap- envelope.</soap:Text></soap:Reason><soap:Detail /></soap:Fault> </soap:Body></soap:Envelope>
更新:
谢谢鲍罗丁,你是当之无愧的. SOAP :: Lite模块似乎没有将soapversion参数传递给SOAP :: Lite :: Serializer对象.我现在使用以下代码初始化SOAP对象,它完美地工作.
my $soap = SOAP::Lite->new(proxy => 'https://sandbox.domainbox.net/'); $soap->default_ns('https://sandbox.domainbox.net/'); $soap->soapversion('1.2'); $soap->serializer->soapversion('1.2');
我应该指出,我还必须调整我的代码以适应Domainbox所需的XML格式,但我现在得到了有效的响应.
我现在唯一的问题是如何处理SOAP :: Lite :: SOM作为消息结果返回的Hash引用.我认为这需要一个单独的问题.
我的问题的答案由鲍罗丁提供.正确的代码是在SOAP :: Lite对象和SOAP :: Lite :: Serializer对象上使用soapversion方法.这是一个工作示例:my $soap = SOAP::Lite->new(proxy => 'https://sandbox.domainbox.net/'); $soap->default_ns('https://sandbox.domainbox.net/'); $soap->soapversion('1.2'); $soap->serializer->soapversion('1.2');