1

I have been wracking my brain to figure this out. I have an XML that get from a soap call. I can echo the result but I can't figure out how to get in there and loop through the data. I'm new to soap (as you might tell).

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Header> <ActivityId xmlns="http://schemas.microsoft.com/2004/09/ServiceModel/Diagnostics" CorrelationId="18b2719b-e13a-41d7-ab1c-eb3319a2fd64">a588ead5-ecce-42bb-bcb3-b6f13ddc3846</ActivityId> </s:Header> <s:Body> <GetMBDataResponse xmlns="http://blah.com/APO"> <GetMBDataResult xmlns:a="http://blah.com/APO/GetGuestData" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <a:Project> <a:ProjectId>12345</a:ProjectId> <a:AlternateId/> <a:Name>Summer Vacation</a:Name> <a:Date>2014-05-17T00:00:00</a:Date> <a:ProjectType/> <a:Organization>My Org</a:Organization> </a:Project> <a:DeletedProject i:nil="true"/> <a:Guests> <a:MBData.BData> <a:ProjectId>12345</a:ProjectId> <a:BId>11979066</a:BId> <a:Name>John Smith</a:Name> <a:Number>101</a:Number> <a:First>John</a:First> <a:Last>Smith</a:Last> </a:MBDData.BData> <a:MBData.BData> <a:ProjectId>12345</a:ProjectId> <a:BId>11979067</a:BId> <a:Name>Nancy Wilson</a:Name> <a:Number>102</a:Number> <a:First i:nil="true"/> <a:Last i:nil="true"/> </a:MBData.BData> </a:Guests> </GetMBDataResult> ... </GetMBDataResponse> </s:Envelope> 

I've tried to simplexml_load_string($xml) after it's returned from the cURL but I can't figure out how to get in there and loop through the MBData and get the details. I'm sure it's obvious but I just can seem to get it.

UPDATE

This is part of the WSDL:

 <xs:complexType name="Authentication"> <xs:sequence> <xs:element name="PartnerId" nillable="true" type="xs:string"/> <xs:element name="UserName" nillable="true" type="xs:string"/> <xs:element name="Password" nillable="true" type="xs:string"/> </xs:sequence> </xs:complexType> 

How would you build your SoapClient authentication. I keep getting: Fatal error: Uncaught SoapFault exception: [a:InternalServiceFault] Object reference not set to an instance of an object. in /var/www/cron-gg-update.php:36 Stack trace: #0 /var/www/cron-gg-update.php(36): SoapClient->__soapCall('GetMBData', Array).

1
  • Don't use cURL for SOAP requests when there's a perfectly good SoapClient class that does it all for you :) Commented Sep 28, 2013 at 23:55

1 Answer 1

0

For this you should use a SOAP Library which gives you the correct output in an array for example.

There are some libs like Nusoap or the internal PHP Soap functions.

Here is an example for a PHP Soap client.

http://php.net/manual/en/soapclient.soapclient.php

Sign up to request clarification or add additional context in comments.

2 Comments

There's no way to read this into an array and loop through it? I'm struggling with PHP Soap. Know of any basic tutorials?
You could try something like this stackoverflow.com/questions/13929566/… but its much easier to use a soap clients ;)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.