PHP SoapClient and Read Attributes

I have found many explanations about how SoapClient expects you to set attributes in a request, but I just cannot find a way to read the attributes from the response.

For example, my SoapClient answer contains the following elements:

... <ns:index> <ns:uid expdate="2013-09-03 14:30:00">JOWtest002</ns:uid> <ns:uid expdate="2013-02-07 15:00:00">JOWtest003</ns:uid> </ns:index> ... 

However, the expdate attribute is never bound to the stdClass index

 ["index"]=> object(stdClass)#80 (1) { ["uid"]=> array(2) { [0]=> string(10) "JOWtest002" [1]=> string(10) "JOWtest003" } } 

I tried using the SoapClient class map to bind it to an object, but unfortunately the WSDL does not define the uid element as complexType, so it also does not display attributes. Binding an β€œindex” to a class does not work.

Any suggestions? I really want to avoid parsing XML by providing it with SimpleXML or DOMDocument.

+6
source share
1 answer

I am a little versed in XML and this is the real challenge. In my experience, and if you are opening up to use a library that has written an excellent wrapper to handle a SOAP response, it would be to implement the Saber XML library found in this link .

It is very easy to send and read answers. The documentation is really good, and they have many examples on their site that will help you make good use of the library.

0
source

All Articles