我编写了从java字符串生成soap消息的方法:
private SOAPMessage createRequest(String msg) {
SOAPMessage request = null;
try {
MessageFactory msgFactory = MessageFactory.newInstance();
request = factory.createMessage();
SOAPPart msgPart = request.getSOAPPart();
SOAPEnvelope envelope = msgPart.getEnvelope();
SOAPBody body = envelope.getBody();
StreamSource _msg = new StreamSource(new StringReader(msg));
msgPart.setContent(_msg);
request.saveChanges();
} catch(Exception ex) {
ex.printStackTrace();
}
}
然后,我尝试生成一些消息。例如:
createRequest("test message");
但是在这里-request.saveChanges();
我发现了这个异常:
com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Error during saving a multipart message
我的错误在哪里?