Similarly to an older post I'm trying to access a web service with JAX-WS using:
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));
where:
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();
}
but I get the error 'The current event is not START_ELEMENT null but 2' (I think on the transformer)
What am I doing wrong :(
Presumably from the parser. I would say a stack trace would be helpful, but Xerces/Xalan has a tendency for screwing those up.
Obvious steps to take:
You should amend your statement
e.getMessage()
to actually print the error message :-) That should help.
System.err.println(e.getMessage());
or preferably
e.printStackTrace();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.