SoapClient返回null,但__last_response被填充,但仍然不能创建对象与simplexml_loa


SoapClient returning null but __last_response is populated but still can't create object with simplexml_load_string

我已经创建了一个SOAP客户端,它使用我无法控制的wsdl。我调用webservice,它返回null

当我从__getLastRequest()复制XML并在SOAP UI中使用它时,我得到一个响应。

当我在soap客户端上查看__last_response时,我可以看到一个xml字符串

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Body>
    <GetResponse xmlns="http://tempuri.org/">
      <GetResult>5923946</GetResult>
    </GetResponse>
  </s:Body>
</s:Envelope>

当我尝试将__last_response传递到simplexml_load_string时,没有创建对象。

为什么不能用两种情况下提供的XML创建对象?

SimpleXML不能加载包含名称空间的xml字符串。我找到的解决方案是删除名称空间。你可以这样做:

$response=str_replace("<s:","",$response);

希望这能解决你的问题