My WSDL contains some <s:extension/> elements and these had some issues when I 
used the default "ADB" bindings. 

When I read the below statement from axis2 documentation I started using  "XML 
beans" binding. If the below API doesn't work with XMLBeans and MTOM, can 
someone point me to the correct API?. When I started debugging this issue I see 
that second attachment stream was being read to a certain extent and then 
suddenly i see the exception.

http://ws.apache.org/axis2/1_0/adb/adb-howto.html


"ADB is meant to be a 'Simple' databinding framework and was not meant to
compile all types of schemas. The following limitations are the most
highlighted.
Complex Extensions and Restrictions, Simple Extensions and Restrictions
    are not supported."


> Date: Tue, 1 Dec 2009 19:05:12 -0300
> Subject: Re: Attempted read on closed stream / unable to read second  
> attachement
> From: [email protected]
> To: [email protected]
> 
> On Tue, Dec 1, 2009 at 7:01 PM, robert lazarski
> <[email protected]> wrote:
> > On Tue, Dec 1, 2009 at 6:51 PM, vasu ts <[email protected]> wrote:
> >> 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?
> >>
> >> _______________
> >
> > Just a quick thought that may be way off: Not sure if
> > messageContext.getAttachmentMap() works with xmlbeans. Might be ADB
> > only. In fact, looking at the docs and from previous experience, I'm
> > pretty sure SWA - you don't mention what you are using - is ADB only.
> > Not sure about the jaxws stuff.
> >
> > Anyways, if you control the client, I'd just send the attachment as a
> > String and accept the 30% bigger payload as unimportant if possible -
> > often its not worth worrying about. Or switch to ADB on the server
> > side. Or implement SWA or whatever for xmlbeans :-) .
> >
> > - R
> >
> 
> Ah, MTOM. I'm 99% sure its ADB only.
> 
> - R
                                          
_________________________________________________________________
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

Reply via email to