PHP SoapClient - 看起来我们没有XML文档

时间:2016-09-21 11:36:52

标签: php xml soap

我正在尝试使用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。任何想法我该怎么办?

1 个答案:

答案 0 :(得分:0)

好的,所以我设法解决了这个愚蠢的问题,在这里使用this技巧。有关更多详细信息,请查看this帖子。希望我让某人成为更好的一天。欢呼声。