我正在尝试使用PHP SoapClient访问.NET SOAP Web服务。问题是我得到以下错误:
看起来我们没有XML文档
当我在客户端对象上调用__getLastResponse()时,xml有点奇怪:
--uuid:a2591cd7-7b7b-44bb-b93e-2750cc651efc+id=14
Content-ID: <http://tempuri.org/0>
Content-Transfer-Encoding: 8bit
Content-Type: application/xop+xml;charset=utf-8;type="application/soap+xml"
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing"><s:Header><a:Action s:mustUnderstand="1">http://tempuri.org/IRemoteRegForDeposit/GetHelloWorldResponse</a:Action><a:RelatesTo>uudi:6e612bfb-6d03-9c4f-ea90-2af98bad1885</a:RelatesTo></s:Header><s:Body><GetHelloWorldResponse xmlns="http://tempuri.org/"><GetHelloWorldResult>Ти ми изпрати числото:1</GetHelloWorldResult></GetHelloWorldResponse></s:Body></s:Envelope>
--uuid:a2591cd7-7b7b-44bb-b93e-2750cc651efc+id=14--
这是我的代码:
$client = new CustomSoapClient($wsdl, array(
'trace' => true,
'soap_version' => SOAP_1_2,
'exceptions' => 0,
'cache_wsdl' => 0,
));
$data = new stdClass();
$data->dummyNumber = '3';
$response = $client->GetHelloWorld($data);
我的CustomSoapClient扩展了PHP的SoapClient并使用此class将ws-address内容添加到soap请求中。
class CustomSoapClient extends SoapClient
{
public function __doRequest($request, $location, $saction, $version, $one_way = NULL)
{
$dom = new DOMDocument();
$dom->loadXML($request);
$wsa = new WSASoap($dom);
$wsa->addAction($saction);
$wsa->addTo($location);
$wsa->addMessageID();
$wsa->addReplyTo();
$request = $wsa->saveXML();
return parent::__doRequest($request, $location, $saction, $version, $one_way);
}
}
我不确定为什么响应不干净xml。任何想法我该怎么办?