[SOAP] Re: how to grab a list of objects from a soap response

From: Date: Mon, 03 Sep 2007 17:12:36 +0000
Subject: [SOAP] Re: how to grab a list of objects from a soap response
References: 1 2 3 4 5  Groups: php.soap 
Request: Send a blank email to php-soap+get-2631@lists.php.net to get a copy of this message
Quoting Milo van der Linden <milo@3dsite.nl> (Seg 03 Set 2007 16:02:00 WEST):
I also prefer not to parse the string for future compatibility with the php soap library.. I am one step further; I now try: Which gives me: string(469) "<Projects><Project><ID>1</ID><Name>LOGIS_2007-1</Name></Project><Project><ID>2</ID><Name>LOGIS_2007-2</Name></Project><Project><ID>3</ID><Name>LOGIS_2007-3-1</Name></Project><Project><ID>4</ID><Name>LOGIS_2007-4</Name></Project><Project><ID>5</ID><Name>LOGIS_2007-5</Name></Project><Project><ID>6</ID><Name>LOGIS_2007-6</Name></Project><Project><ID>7</ID><Name>MWI_TEST_LOCATIEVELD</Name></Project><Project><ID>8</ID><Name>MWI_TEST_LOCATIE_2</Name></Project></Projects>" So at least the string only contains a Projects collection now. I also noticed that thw WDSL definition does not contain a description of the content of the Response, it simply states "any"
Viewing this thread I the WSDL just return the XML with the result. So you have to parse the result. IMO you should use simplexml to parse the xml string. It's very simple to use. $xml = new SimpleXMLElement($your_xml_string); foreach ($xml->Project as $proj) { echo $proj->ID . "\n"; echo $proj->Name . "\n"; echo "-------------\n"; } -- Carlos Pires

« previous php.soap (#2631) next »