连续调用' SOAPMessage.writeTo'抛出读错误

时间:2015-03-05 12:40:32

标签: java soap saaj

我的应用程序中的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)

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

1 个答案:

答案 0 :(得分:1)

我找到了原因。是'MyDataSource'类返回相同的inputStream。每次接到电话时都会返回一个新的InputStream。

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

        //return inputStream;
InputStream inputStream= new FileInputStream(file);
return inputStream;
    }
}