php - 如何在 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 的值我该怎么做
解决方案
推荐阅读
- c# - 通过异步示例了解 C# 中的并行编程
- dynamics-crm - 如何在不将其授予用户的情况下授予工作流权限?
- node.js - 数据湖 AWS 无服务器 Amazon S3
- laravel - 如何使用 Inertia::render 将某个模型的关系显示在表格中?
- c - 将标准输出重定向到文件并使用函数重新建立标准输出
- android - 在对话框中单击确定后如何刷新我的片段
- c# - 如何在 UWP 中将图像位深度转换为 16 位?
- android - 为什么 android:textDirection="locale" 不适用于 EditText 的阿拉伯语提示密码?
- java - 更新后无法构建android项目,错误:此构建中使用了已弃用的Gradle功能,使其与Gradle 5.0不兼容
- python-3.x - 一个python游戏猜数字的问题