与较早的帖子类似,我正在尝试使用 JAX-WS 访问 Web 服务:
Dispatch<Source> sourceDispatch = null;
sourceDispatch = service.createDispatch(portQName, Source.class, Service.Mode.PAYLOAD);
Source result = sourceDispatch.invoke(new StreamSource(new StringReader(req)));
System.out.println(sourceToXML(result));
在哪里:
private static String sourceToXML(Source result) {
Node rootNode= null;
try {
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer();
DOMResult domResult = new DOMResult();
transformer.transform(result, domResult );
rootNode = (Node) domResult.getNode();
} catch (TransformerException e) {
e.getMessage();
}
return rootNode.getFirstChild().getNodeValue();
}
但我收到错误“当前事件不是 START_ELEMENT null 而是 2”(我认为在变压器上)
我究竟做错了什么 :(