【发布时间】:2015-06-01 02:02:46
【问题描述】:
我有一个想要保存到 XML 文件的 SOAP 响应。当响应写入文件时,SOAP 信封也随之写入,导致 XML 文件因错误而无用:
XML declaration allowed only at the start of the document in ...
在这种情况下,XML 被声明了两次:
<?xml version="1.0" encoding="ISO-8859-1"?>
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body><ns1:NDFDgenResponse xmlns:ns1="http://graphical.weather.gov/xml/DWMLgen/wsdl/ndfdXML.wsdl">
<dwmlOut xsi:type="xsd:string">
<?xml version="1.0"?>
...
有没有什么好的方法可以去掉这个 SOAP 信封,只保存它之间的内容?
我是这样写对文件的响应的:
$toWrite = htmlspecialchars_decode($client->__getLastResponse());
$fp = fopen('weather.xml', 'w');
fwrite($fp, $toWrite);
fclose($fp);
【问题讨论】:
标签: php xml web-services soap