0

我正在尝试使用如下所示的示例请求从 PHP 向 SOAP Web 服务进行 Web 服务调用:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.somedomain.com/">
   <soapenv:Header/>
   <soapenv:Body>
      <ws:SearchMarketplaceSku>
         <ws:Request>
             <ws:Security>
               <ws:PartnerKey>[suppressed]</ws:PartnerKey>
               <ws:Password>[suppressed]</ws:Password>
            </ws:Security>
            <ws:AvailableOnDate>2012-04-03T00:00:00</ws:AvailableOnDate>
            <ws:IncludeStateDetails>true</ws:IncludeStateDetails>
            <ws:State>CA</ws:State>
         </ws:Request>
      </ws:SearchMarketplaceSku>
   </soapenv:Body>
</soapenv:Envelope>

正在使用的 PHP 代码是:

$soapClient = new SoapClient($wsdlUrl);   
$ap_param = array('PartnerKey'    =>    $PartnerKey, 'Password'    =>    $metapackPassword, 'AvailableOnDate' => '2012-04-03T00:00:00','IncludeStateDetails'=>true, 'State'=>'CA');
$info = $soapClient->__call("SearchMarketplaceSku", $ap_param);

Web 服务调用导致“请求未正确指定;服务器无法反序列化请求”错误?问题是什么?$ap_param 数组是否需要包含所有与 XML 对应的嵌套节点?有没有更简单的方法可以使用“WSDL”模式进行此调用?

谢谢你的帮助

4

1 回答 1

2

PartnerKey 和 Password 必须位于密钥 Security 下的数组中:

$ap_param = array(
'Security' => array(
    'PartnerKey'    =>    $PartnerKey,
    'Password'    =>    $metapackPassword
),
'AvailableOnDate' => '2012-04-03T00:00:00',
'IncludeStateDetails'=>true, 'State'=>'CA'
);
于 2012-04-04T20:52:04.690 回答