I use native soapclient () to call WSDL, but I cannot use simplexml to parse the result. I get an error message:
Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 1: parser error : Extra content at the end of the document
This doesn't seem to be a namespace problem, and I already tried the fix mentioned elsewhere on the site to remove the colons from the input string.
EDIT:
Thanks Gordon
Yes you are right. The server is a Microsoft site using data sets.
If I declare a client soap with a trace equal to true:
$soapClient = new soapclient($this->wsdlUrl,array('trace'=>true));
and then extracting the raw XML from the response:
$soapResult = $soapClient->GetScheduledSectors(); $responseXml = $soapClient->__getLastResponse(); $xml = simplexml_load_string($responseXml, NULL, NULL, "http://schemas.xmlsoap.org/soap/envelope/");
then I get:
SimpleXMLElement Object ( [Body] => SimpleXMLElement Object ( ) )
The response XML header and the first tag are as follows:
<?xml version='1.0'?> <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:Body> <GetScheduledSectorsResponse xmlns="https://www.kulula.com/k3api/"> <GetScheduledSectorsResult msdata:SchemaSerializationMode="ExcludeSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xs:schema id="dsFlight" targetNamespace="http://tempuri.org/dsFlight.xsd" attributeFormDefault="qualified" elementFormDefault="qualified" xmlns:mstns="http://tempuri.org/dsFlight.xsd" xmlns="http://tempuri.org/dsFlight.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msprop="urn:schemas-microsoft-com:xml-msprop"> <xs:element name="dsFlight" msdata:IsDataSet="true" msdata:UseCurrentLocale="true" msprop:ExecutionTime="1140"> <xs:complexType> <xs:choice minOccurs="0" maxOccurs="unbounded"/> </xs:complexType> </xs:element> </xs:schema> <diffgr:diffgram xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"> <dsFlight xmlns="http://tempuri.org/dsFlight.xsd"> <FlightSector diffgr:id="FlightSector1" msdata:rowOrder="0"> <FlightSectorId>1</FlightSectorId> <FlightSectorName>JNBCPT</FlightSectorName> <FromAirport>OR Tambo (Jo'burg)</FromAirport> <ToAirport>Cape Town</ToAirport> <DepartureAirportId>1</DepartureAirportId> <ArrivalAirportId>2</ArrivalAirportId> <AirlineCode>BA</AirlineCode> <Ordernumber>100</Ordernumber> <FlightZoneId>1</FlightZoneId> <DepartureCountryCode>ZA</DepartureCountryCode> <DepartureContinentCode>AF</DepartureContinentCode> </FlightSector>
I also tried registering the following namespaces:
$xml = simplexml_load_string($this->responseXml, NULL, NULL, "http://schemas.xmlsoap.org/soap/envelope/"); $xml->registerXPathNamespace('soap', 'http://schemas.xmlsoap.org/soap/envelope/'); $xml->registerXPathNamespace('xsi', 'http://www.w3.org/2001/XMLSchema-instance'); $xml->registerXPathNamespace('xsd', 'http://www.w3.org/2001/XMLSchema'); $xml->registerXPathNamespace('diffgr', 'urn:schemas-microsoft-com:xml-diffgram-v1'); $xml->registerXPathNamespace('mstns', 'http://tempuri.org/dsFlight.xsd'); $xml->registerXPathNamespace('msprop', 'urn:schemas-microsoft-com:xml-msprop');
but still get an empty object in $ xml