如何在java中将org.jdom.Document转换为javax.xml.soap.SOAPMessage?
答案 0 :(得分:2)
像这样的东西应该有用,虽然它有点笨重但不会很快:
MessageFactory messageFactory = MessageFactory.newInstance();
public SOAPMessage toMessage(Document jdomDocument) throws IOException, SOAPException {
String xml = new XMLOutputter().outputString(jdomDocument);
InputStream inputStream = new StringBufferInputStream(xml);
return messageFactory.createMessage(null, inputStream);
}
这假定JDOM文档在其整体,标题和所有内容中表示有效的SOAP消息结构。