Я использую native soapclient () для вызова WSDL, но не могу использовать simplexml для анализа результата. Я постоянно получаю сообщение об ошибке:
Warning: simplexml_load_string() [function.simplexml-load-string]:
Entity: line 1: parser error : Extra content at the end of the document
Это не похоже на проблему с пространством имен, и я уже пробовал патч, упомянутый в другом месте на сайте, чтобы удалить двоеточия из входной строки.
EDIT:
Спасибо, Гордон
Да, вы правы. Сервер является сайтом Microsoft, использующим наборы данных.
Если я объявлю мыльный клиент с трассировкой, установленной в true:
$soapClient = new soapclient($this->wsdlUrl,array('trace'=>true));
и затем извлечение необработанного XML из ответа:
$soapResult = $soapClient->GetScheduledSectors();
$responseXml = $soapClient->__getLastResponse();
$xml = simplexml_load_string($responseXml, NULL, NULL, "http://schemas.xmlsoap.org/soap/envelope/");
тогда я получаю:
SimpleXMLElement Object
(
[Body] => SimpleXMLElement Object
(
)
)
XML-заголовок ответа и первый тег выглядят так:
<?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>O.R. 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>
Я также попытался зарегистрировать следующие пространства имен:
$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');
но все равно получите пустой объект в $ xml