【问题标题】:Parse 2 difference Soap Response PHP解析 2 差异 Soap 响应 PHP
【发布时间】:2019-02-03 13:52:55
【问题描述】:

我是 php 新手,如何解析来自 soap xml 的 2 个不同响应?

响应 1

'<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:MobileAgentAPI="urn:openApi">
<SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<MobileAgentAPI:invokeResponse>
	<SOAP-ENV:BodySOAP-ENV:Body>
		<values xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="MobileAgentAPI:SoapMapValue[13]">
	<item>
		<name>amount</name>
		<singleValue>5000</singleValue>
	</item>
	<item>
		<name>balance</name>
		<singleValue>12210000</singleValue>
	</item>
	<item>
		<name>lastBalance</name>
		<singleValue>12215000</singleValue>
	</item>
	<item>
		<name>returnCode</name>
		<singleValue>00</singleValue>
	</item>
	<item>

响应 2

 <?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:MobileAgentAPI="urn:openApi"><SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><MobileAgentAPI:invokeResponse><invokeReturn><values xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="MobileAgentAPI:SoapMapValue[6]"><item><name>balance</name><singleValue>15420000</singleValue></item><item><name>returnCode</name><singleValue>01</singleValue></item><item><name>transactionStatus</name><singleValue>02</singleValue></item><item><name>errorCode</name><singleValue>324</singleValue></item><item><name>errorDescription</name><singleValue>(324) Maaf, transaksi pada 01/10/18 06:00 gagal. Nomor tujuan tidak terdaftar. =</singleValue></item><item><name>tran

我尝试使用 DOM 文档,但如果我们有 2 个响应,结果是错误

【问题讨论】:

  • 请提问。你说的没有道理。完成您的问题或将其删除。

标签: php xml soap response


【解决方案1】:

您为什么尝试解析 XML 响应? 使用原生 PHP SoapClient 类,您至少可以处理 PHP 数组或更好的对象。

使用 WSDL 到 PHP 生成器,这样您就不会想知道如何构造请求数据或如何处理响应,因为您将始终使用更好的 OOP 方法。试试PackageGenerator 项目。

【讨论】:

  • 先生,我想得到我的项目的回复,但是如果我得到 2 个不同的回复,我该怎么办
猜你喜欢
  • 2012-09-10
  • 2016-09-03
  • 2014-03-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-04-22
相关资源
最近更新 更多