PHP: How to process SOAP response to get a tag value?

后端 未结 2 812
小蘑菇
小蘑菇 2020-12-20 09:53

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



        
相关标签:
2条回答
  • 2020-12-20 10:11

    Let me save a whole lot of trouble and help you with your dataset instead (I'm assuming this is your web service, if it isn't I apologize).

    Instead of serializing the whole dataset, run it through this function first and return it as a string.

    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
    

    This will strip out .NET's schema and leave you with easily parsed XML (even SimpleXML will be able to parse it). You'll need System.Text and System.Xml

    0 讨论(0)
  • 2020-12-20 10:19

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

    0 讨论(0)
提交回复
热议问题