Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP:如何处理SOAP响应以获取标记值?_Php_Xml_Soap - Fatal编程技术网

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

PHP:如何处理SOAP响应以获取标记值?,php,xml,soap,Php,Xml,Soap,我在var$SOAP\u响应中有一个SOAP响应,如下所示: <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.

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

<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>
返回空的对象数组


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

让我省去很多麻烦,帮助您处理数据集(我假设这是您的web服务,如果不是,我道歉)

不要序列化整个数据集,而是首先通过此函数运行它,并将其作为字符串返回

Public Function FormatDataSet(ByVal ds As DataSet)
    Try
        Dim xmlstream As New StringBuilder
        Dim write As XmlWriter = XmlWriter.Create(xmlstream)
        write.WriteProcessingInstruction("xml", "version='1.0' encoding='utf-8'")
        ds.WriteXml(write)
        Return xmlstream.ToString()
    Catch ex As Exception
        Return ex.Message
    End Try
End Function

这将去掉.NET的模式,并为您留下易于解析的XML(即使SimpleXML也能够解析它)。您将需要System.Text和System.Xml

我可以使用SoapClient和
\uu doRequest()函数来完成它。Zend_Soap_客户端也使用Soap客户端。所以我选择了SoapClient。

为什么不能使用SoapClient?另外,您可能还想看看Zends Soap客户端和服务器:非常易于使用,文档记录良好等等。。。祝你好运我很感谢您的努力,但这不是我的web服务。太糟糕了-构建.NET web服务的人似乎总是决定返回复杂的对象。对我来说,我看到太多的web服务在使用非常开放的架构的.NET平台上生成,太多的web服务返回XML“blob”作为字符串,并期望您在以后解析它。
Public Function FormatDataSet(ByVal ds As DataSet)
    Try
        Dim xmlstream As New StringBuilder
        Dim write As XmlWriter = XmlWriter.Create(xmlstream)
        write.WriteProcessingInstruction("xml", "version='1.0' encoding='utf-8'")
        ds.WriteXml(write)
        Return xmlstream.ToString()
    Catch ex As Exception
        Return ex.Message
    End Try
End Function