我正在使用 WebServiceTemplate 类,并且将从 Web 服务接收到的 XML 响应存储在一个文件中。但是 .xml 文件由于某种原因包含所有<
,>
保存为;<
和;>
.
有什么办法可以.xml
在保存之前将其转换为正确的文件?
InputStream inputStream = new WebServiceClientImpl().getClass().getResourceAsStream("Request.xml");
StreamSource source = new StreamSource(inputStream2);
StreamResult result = new StreamResult(new File("Response.xml"));
webServiceTemplate.sendSourceAndReceiveToResult(defaultURI,source, result);
请求.xml:
<list>
<requestXmlString xs:type="type:string" xmlns:xs="http://www.w3.org/2000/XMLSchema- instance">
<![CDATA[<request operationName="list" locale="en">
<resourceDescriptor name="" wsType="folder" uriString="/" isNew="false">
<label>null</label>
</resourceDescriptor>
</request>]]>
</requestXmlString>
</list>
响应.xml
<?xml version="1.0" encoding="UTF-8"?><listResponse xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><listReturn xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xsd:string"><?xml version="1.0" encoding="UTF-8"?>
<operationResult version="2.0.1">
<returnCode><![CDATA[0]]></returnCode>
<resourceDescriptor name="Record1" wsType="reportUnit" uriString="/xyz" isNew="false">
<label><![RECORD 1]]></label>
<creationDate>1338285680000</creationDate>
<resourceProperty name="PROP_RESOURCE_TYPE">
<value><!