PHP:如何处理 SOAP 响应以获取标记值?

PHP: How to process SOAP response to get a tag value?(PHP:如何处理 SOAP 响应以获取标记值?)
本文介绍了PHP:如何处理 SOAP 响应以获取标记值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我在 var $soap_response 中有一个 SOAP 响应,如下所示:

I've a SOAP response in a var $soap_response like this:

<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:clr="http://schemas.microsoft.com/soap/encoding/clr/1.0">
   <SOAP-ENV:Header>
      <h3:__MethodSignature xsi:type="SOAP-ENC:methodSignature" SOAP-ENC:root="1" xmlns:h3="http://schemas.microsoft.com/clr/soap/messageProperties" xmlns:a2="http://schemas.microsoft.com/clr/ns/System.Collections">xsd:string a2:Hashtable</h3:__MethodSignature>
   </SOAP-ENV:Header>
   <SOAP-ENV:Body>
      <i4:ReturnDataSetResponse id="ref-1" xmlns:i4="http://schemas.microsoft.com/clr/nsassem/TOIServerAppl.clsRSchedule/TOIServerAppl">
         <return href="#ref-6"/>
      </i4:ReturnDataSetResponse>
      <a3:DataSet id="ref-6" xmlns:a3="http://schemas.microsoft.com/clr/nsassem/System.Data/System.Data%2C%20Version%3D1.0.5000.0%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3Db77a5c561934e089">
         <XmlSchema id="ref-7"><![CDATA[<?xml version="1.0" encoding="utf-16"?>
            <xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
              <xs:element name="NewDataSet" msdata:IsDataSet="true">
                <xs:complexType>
                  <xs:choice maxOccurs="unbounded">
                    <xs:element name="Table">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="id" type="xs:long" msdata:targetNamespace="" minOccurs="0" />
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                  </xs:choice>
                </xs:complexType>
              </xs:element>
            </xs:schema>]]>
        </XmlSchema>
        <XmlDiffGram id="ref-8">
            <id>4437031</id>
        </XmlDiffGram>
      </a3:DataSet>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

如何从 4437031 中提取 id 值?

How can I extract id value from <id>4437031</id>?

simplexml_load_string($soap_response);

返回空对象数组.

我看到有些地方可能需要替换所有这些命名空间才能使其正常工作?

I've seen someplaces that I might have to replace all those namespaces to make it work?

推荐答案

我能够使用 SoapClient 和 __doRequest() 函数来做到这一点.Zend_Soap_client 也使用 SoapClient.所以我选择了 SoapClient.

I was able to do it with SoapClient and __doRequest() function. Zend_Soap_client also uses SoapClient. So I chose SoapClient.

这篇关于PHP:如何处理 SOAP 响应以获取标记值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

Subtract time in PHP(在 PHP 中减去时间)
Limit execution time of an function or command PHP(限制函数或命令 PHP 的执行时间)
How to sum N number of time (HH:MM Format)?(如何求和 N 次(HH:MM 格式)?)
How to get current time in milliseconds in PHP?(如何在 PHP 中以毫秒为单位获取当前时间?)
How to check if time is between two times in PHP(如何检查时间是否在 PHP 中的两次之间)
Convert number of minutes into hours amp; minutes using PHP(将分钟数转换为小时数分钟使用 PHP)