0

How do I convert SOAP response like this to php array using SimpleXML?

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Header>
    <eWAYHeader xmlns="http://www.eway.com.au/gateway/rebill/manageRebill">
      <eWAYCustomerID>9******5</eWAYCustomerID>
      <Username>ac****@si****.com.sand</Username>
      <Password>*******</Password>
    </eWAYHeader>
  </soap:Header>
  <soap:Body>
    <CreateRebillCustomerResponse xmlns="http://www.eway.com.au/gateway/rebill/manageRebill">
      <CreateRebillCustomerResult>
        <Result>Success</Result>
        <ErrorSeverity />
        <ErrorDetails />
        <RebillCustomerID>60066328</RebillCustomerID>
      </CreateRebillCustomerResult>
    </CreateRebillCustomerResponse>
  </soap:Body>
</soap:Envelope>
Juicy Scripter
  • 25,778
  • 6
  • 72
  • 93
Achintha Samindika
  • 1,944
  • 1
  • 20
  • 31
  • Can you please explain how you got this and what you intend to do with it, cause i smell a bad case of "Not using technologies correctly" here – Mathieu Dumoulin Jun 20 '12 at 19:32
  • I'm developing a application using Eway payment gateway API. I'm getting this after I send SOAP request using CURL in php. This is come as response. – Achintha Samindika Jun 20 '12 at 19:34
  • 1
    @AchinthaSamindika, any reason you want it to be associative array? The SOAP response you get can be pretty easily parsed/traversed with XPath (see some good point [here](http://stackoverflow.com/a/740795/155033)), also using [SOAP extension](http://php.net/soap) seems a better choice. – Juicy Scripter Jun 20 '12 at 19:38
  • I'm newbie and still not got how to traverse. If you can it in using this xml it will great help. Thanks – Achintha Samindika Jun 20 '12 at 19:41
  • @AchinthaSamindika, loork a bit within linker/related questions in the right sidebar and you'll figure way how to do it ;) – Juicy Scripter Jun 20 '12 at 19:43
  • Please can someone show me how to extract Success 60066328 Now this is my second day, I'm newbie to SOAP and very hard to find how to do it. Please – Achintha Samindika Jun 21 '12 at 08:18

1 Answers1

3

You might want to look at SoapClient class then? It'll save HEAPS of trouble.

Juicy Scripter
  • 25,778
  • 6
  • 72
  • 93
Mathieu Dumoulin
  • 12,126
  • 7
  • 43
  • 71