替换 Apache CXF 版本 3.1.16 中缺少的 org.apache.cxf.helpers.DOMUtils.writeXml(Node n, OutputStream os)
Replace org.apache.cxf.helpers.DOMUtils.writeXml(Node n, OutputStream os) missing in Apache CXF version 3.1.16
我正在从 JBoss EAP 6.4
迁移到 EAP 7.1
。我已将 Apache CXF 从 2.7.14 更新到 3.1.16,但现在我缺少 DOMUtils.writeXml(Node n, OutputStream os)
方法。在这种情况下,哪种替换方式最好?
SOAPMessage soapMessage = message.getContent(SOAPMessage.class);
SOAPBody env = soapMessage.getSOAPPart().getEnvelope().getBody();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DOMUtils.writeXml(env, baos);
String soapBody = baos.toString();
我用 javax.xml.transform.TransformerFactory
替换了 DOMUtils.writeXml(Node n, OutputStream os)
:
SOAPMessage soapMessage = message.getContent(SOAPMessage.class);
SOAPBody env = message.getSOAPPart().getEnvelope().getBody();
javax.xml.transform.dom.DOMSource source = new javax.xml.transform.dom.DOMSource(env);
StringWriter stringResult = new StringWriter();
javax.xml.transform.TransformerFactory.newInstance().newTransformer().transform(source, new StreamResult(stringResult));
String soapBody = stringResult.toString();
我正在从 JBoss EAP 6.4
迁移到 EAP 7.1
。我已将 Apache CXF 从 2.7.14 更新到 3.1.16,但现在我缺少 DOMUtils.writeXml(Node n, OutputStream os)
方法。在这种情况下,哪种替换方式最好?
SOAPMessage soapMessage = message.getContent(SOAPMessage.class);
SOAPBody env = soapMessage.getSOAPPart().getEnvelope().getBody();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DOMUtils.writeXml(env, baos);
String soapBody = baos.toString();
我用 javax.xml.transform.TransformerFactory
替换了 DOMUtils.writeXml(Node n, OutputStream os)
:
SOAPMessage soapMessage = message.getContent(SOAPMessage.class);
SOAPBody env = message.getSOAPPart().getEnvelope().getBody();
javax.xml.transform.dom.DOMSource source = new javax.xml.transform.dom.DOMSource(env);
StringWriter stringResult = new StringWriter();
javax.xml.transform.TransformerFactory.newInstance().newTransformer().transform(source, new StreamResult(stringResult));
String soapBody = stringResult.toString();