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 :(