如何调用.NET Web服务调用没有“无法反序列化请求”错误的.NET Web服务?

时间:2012-04-04 20:49:18

标签: php soap

我正在尝试使用示例请求从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”模式进行此调用?

感谢您的帮助

1 个答案:

答案 0 :(得分:2)

PartnerKey和密码必须位于密钥Security:

下的数组中
$ap_param = array(
'Security' => array(
    'PartnerKey'    =>    $PartnerKey,
    'Password'    =>    $metapackPassword
),
'AvailableOnDate' => '2012-04-03T00:00:00',
'IncludeStateDetails'=>true, 'State'=>'CA'
);