【发布时间】:2013-07-30 14:56:26
【问题描述】:
这是我第一次在这里寻求帮助,希望有人能帮助我。
我的任务是本地化我们的 ant 构建过程,以帮助减少构建时间。
这个想法类似于构建一个 ant 任务,该任务下载与特定服务关联的 WSDL 并将它们保存在本地。长话短说,这已经完成,但由于某种原因,在使用本地文件构建服务时,我在第一个导入的 XSD 中收到“prolog 中不允许内容”错误。
我搜索过论坛,最常见的回答是序言之前的隐藏字符,但我检查了十六进制代码并且没有隐藏字符。
这是 WSDL 序言
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
这是第一个 XSD 序言
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
十六进制序言
3C3F786D6C2076657273696F6E3D2231
2E302220656E636F64696E673D227574
662D3822207374616E64616C6F6E653D
226E6F223F3E
与远程版本相同。
这也是下载的 XSD 和 WSDL 的保存方式。
private Document convertToXML(String xmlSource) throws Exception {
DocumentBuilder builder = documentBuilderFactory.newDocumentBuilder();
Document document = builder.parse(new InputSource(new StringReader(xmlSource)));
return document;
}
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty(OutputKeys.STANDALONE, "no");
transformer.setOutputProperty(OutputKeys.ENCODING, "utf-8");
Result output = new StreamResult(new File(filePath));
让我知道我是否应该更具体或是否需要添加更多信息。
谢谢。
【问题讨论】:
-
好的,我认为这一定与保存文件的方式有关,因为我只是将现有本地 XSD 中的代码替换为下载版本中的代码,并且运行良好...
-
谢谢,其实我只是想通了。一旦我将所有模式放入与 WSDL 相同的文件夹并更改 schemaLocation 以匹配它,我就将 WSDL 中的 schemaLocation 设置为“exampleschemas\example1\schema.xsd”。