首页 > 解决方案 > 如何在 PHP 中解析 SOAP XML

问题描述

我写这段代码

$Data=date("Y/m/d");
$UserName="xxx";
$password="xxx";
$StationCode="xxx";
$ConsignorAccount="xxx";
$soapclient = new SoapClient("http://api.skynetwwe.info/eComApiV1.svc?wsdl");
$param=array('UserName'=>$UserName, 'Password'=>$password, 'StationCode'=>$StationCode, 'ConsignorAccount'=>$ConsignorAccount);
$response =$soapclient->VerifyUserAccount($param);
echo '<br><br><br>';
$array = json_decode(json_encode($response));  
var_dump($response);
echo '<br><br><br>';
var_dump($array);
$xmlObject = simplexml_load_string($response);

它给了我这个结果

object(stdClass)#2 (1) { ["VerifyUserAccountResult"]=> string(336) "SUC005LOGIN DETAILS HAVE BEEN VERIFIED SUCCESSSFULLY7f969968-14a3-4ea9-a728-d55c53503a5b" }

object(stdClass)#3 (1) { ["VerifyUserAccountResult"]=> string(336) "SUC005LOGIN DETAILS HAVE BEEN VERIFIED SUCCESSSFULLY7f969968-14a3-4ea9-a728-d55c53503a5b" }

但它应该给我这样的结果

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<VerifyUserAccountResponse xmlns="http://tempuri.org/">
<VerifyUserAccountResult><![CDATA[<?xml version="1.0" encoding="utf-8"?>
<Response xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<StatusCode>SUC005</StatusCode>
<StatusDescription>LOGIN DETAILS HAVE BEEN DERIFIED SUCCESSSFULLY</StatusDescription>
<RequestID>15baac9e-ba4a-458d-953d-05443ddc33c0</RequestID>
</Response>]]>
</VerifyUserAccountResult>
</VerifyUserAccountResponse>
</s:Body>
</s:Envelope>

请我需要阅读 RequestID 和 StatusCode 的值我该怎么做

标签: phpsoap

解决方案


推荐阅读