脚本宝典收集整理的这篇文章主要介绍了php – 无法使用SimpleXML解析Soap响应,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
Warning: simplexML_load_string() [function.simplexml-load-string]: EntITy: line 1: parser error : Extra content at the end of the document
这看起来不像命名空间问题,我已经尝试过网站上其他地方提到的补丁来从输入字符串中删除冒号.
编辑:
谢谢,戈登
如果我将soap客户端声明为trace设置为true:
$soapClient = new soapclient($this->wsdlUrl,array('trace'=>true));
然后从响应中检索原始XML:
$soaPResult = $soapClient->GetScheduledSectors(); $responseXml = $soapClient->__getLastResponse(); $xml = simplexml_load_string($responseXml,NULL,"http://schemas.xmlsoap.org/soap/enveloPE/");
然后我得到:
SimpleXMLElement Object ( [Body] => SimpleXMLElement Object ( ) )
<?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,"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中获得一个空对象
然而,当我需要解析SOAP时,我重新考虑了How to parse SOAP XML?,并在PHP 5本机Soap客户端上找到了很好的信息.
以上是脚本宝典为你收集整理的php – 无法使用SimpleXML解析Soap响应全部内容,希望文章能够帮你解决php – 无法使用SimpleXML解析Soap响应所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。