0

我的应用程序中的 SOAP 消息包含从文件创建的附件。当我打电话给soapMessage.writeTo(System.out); 不止一次,它会引发以下异常:

SEVERE: SAAJ0540: Error during saving a multipart message
com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Error during saving a multipart message
    at com.sun.xml.internal.messaging.saaj.soap.MessageImpl.writeTo(MessageImpl.java:1233)
    at main.SOAPMTOMUtilityTest.main(SOAPMTOMUtilityTest.java:102)
Caused by: java.io.IOException: Read error
    at java.io.FileInputStream.readBytes(Native Method)

这是一个错误吗?还是我做错了什么?

4

1 回答 1

1

我找到了原因。它是返回相同输入流的“MyDataSource”类。每次收到调用时,它都会返回一个新的 InputStream。

public class MyDataSource implements DataSource {
    public InputStream getInputStream() throws IOException {

        //return inputStream;
InputStream inputStream= new FileInputStream(file);
return inputStream;
    }
}
于 2015-03-05T14:31:52.180 回答