0
Ich versuche, einen Web-Service mit JAX-WS für den Zugriff mit:Falscher Encoding in JAX-WS Versand Antwort
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(sourceToXMLString(result));
wo:
private static String sourceToXMLString(Source result)
throws TransformerConfigurationException, TransformerException {
String xmlResult = null;
try {
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer();
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
transformer.setOutputProperty(OutputKeys.METHOD, "xml");
transformer.setOutputProperty(OutputKeys.ENCODING, "utf-8");
OutputStream out = new ByteArrayOutputStream();
StreamResult streamResult = new StreamResult();
streamResult.setOutputStream(out);
transformer.transform(result, streamResult);
xmlResult = streamResult.getOutputStream().toString();
} catch (TransformerException e) {
e.printStackTrace();
}
return xmlResult;
}
Als ich das Ergebnis auf einem utf drucken -8 Seite Die UTF-8 Zeichen werden nicht korrekt angezeigt.
Da die WS funktioniert gut mit anderen Tools (gibt UTF-8 in Ordnung), glaube ich, dass es ein Problem mit meiner Transformation sourceToXMLString(). Könnte das meine Kodierung zerstören?