0

I m trying to return an xpath answer to a soap client (i am using an xml file as database). The method works fine when it's called on the server side, unfortunatelly, the client always get an annoying " looks like we got no XML document " error, with this kind of xml answer:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn://localhost/projet/srv" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns2="http://xml.apache.org/xml-soap" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:getTypesVehiculeResponse>
<return SOAP-ENC:arrayType="SOAP-ENC:Struct[4]" xsi:type="SOAP-ENC:Array">
<item xsi:type="SOAP-ENC:Struct">
<@attributes xsi:type="ns2:Map">
<item>
<key xsi:type="xsd:string">id</key>
<value xsi:type="xsd:string">0</value>
</item>
...
</return>
</ns1:getTypesVehiculeResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Should I use another way to send my XML database answers than directly return xpath answer?

hakre
  • 193,403
  • 52
  • 435
  • 836
Anthony Bobenrieth
  • 2,758
  • 1
  • 26
  • 38
  • PHP's [SoapClient](http://php.net/manual/en/class.soapclient.php) should give you an array of data - why do you need xpath? If you're trying to parse HTML, why not just retrieve it with cURL or `file_get_contents()`? – Tobias Fünke Jan 27 '13 at 21:51
  • I am using xpath to query the xml file that is acting like a database (on the server side). – Anthony Bobenrieth Jan 27 '13 at 21:56
  • Okay, but I'm saying you may not need to. Can you give an example of what xpath query you're trying to use? – Tobias Fünke Jan 27 '13 at 21:59
  • For the moment i only use simple queries like : /bdd/typevehicules/* to retrieve all child elements of a category, but in the future i would like to be able to filter the answer. – Anthony Bobenrieth Jan 27 '13 at 22:05

1 Answers1

2

SoapClient should eliminate the need for xpath querying since it already parses the SOAP XML, but if you still want to use xpath, you can try using simplexml as per this answer. If you have an issue with namespaces, try this

Community
  • 1
  • 1
Tobias Fünke
  • 2,034
  • 3
  • 24
  • 38