Hi all,
Binding: XML beans
Axis2 : 1.4.1 and 1.5.1
My web service returns two attachments when an operation is executed. I am
able to read the first attachment but when I try to read the second attachment
its throwing "Attempted read on closed stream" exception. I looked at
wireshark's logs and I see all the binary data for the attachments is being
transferred correctly from the web service server to the client
I looked through the user list archives and also tried several ways of reading
the attachments but every time I see the same issue. Below is the sample code
stub._getServiceClient().getOptions().setProperty(
Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE );
MessageContext messageContext =
stub._getServiceClient().getLastOperationContext().getMessageContext(
WSDL2Constants.MESSAGE_LABEL_IN );
Attachments attachments = messageContext.getAttachmentMap();
if ( attachments != null )
{
String[] contentIds = attachments.getAllContentIDs();
for ( int i = 0; i < contentIds.length; i++ )
{
DataHandler dataHandler = messageContext.getAttachment(
contentIds[i] );
String filePath = m_temp + contentIds[i];
try
{
FileOutputStream fos = new FileOutputStream( filePath );
dataHandler.writeTo( fos );
fos.flush();
fos.close();
}
catch ( IOException ioe )
{
ioe.printStackTrace();
}
}
}
any ideas on how I can resolve this issues?
_________________________________________________________________
Windows Live Hotmail gives you a free,exclusive gift.
http://www.microsoft.com/windows/windowslive/hotmail_bl1/hotmail_bl1.aspx?ocid=PID23879::T:WLMTAGL:ON:WL:en-ww:WM_IMHM_7:092009