You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Axis User <ax...@gmail.com> on 2005/08/01 16:14:44 UTC

reading large attachments

Hi,
First some info...
 
Platform: Axis 1.2.1, Java 1.5.0_04-b05, Linux 2.6.11.4-20a-default

Aim: to send a zip file attached to a SOAP message and save it to a
directory. Zip files will on average be around 50Mb.

Code:
//On the client side I add attachments as below:

DataHandler handler = new DataHandler(new FileDataSource(file));
stub.addAttachment(handler);

//server side retrieval
MessageContext msgContext = MessageContext.getCurrentContext();
Message requestMessage = msgContext.getRequestMessage();
int numAttachments = requestMessage.getAttachmentsImpl().getAttachmentCount();

Problem:
The problem seems to be to me that my service method is being invoked
before the entire attachment has been transferred hence numAttachments
== 0 even though the client always sends an attachment. Is there a way
to determine that the entire message has been received before querying
the number of attachments? In this case the attachments are ~45mb

Thanks,
Mike

Re: reading large attachments

Posted by Axis User <ax...@gmail.com>.
hi,
problem solved - it seemed to be caused by the stub reference being
shared amongst threads. Having each thread construct a locator and get
a new reference or synchronizing the attachment adding works fine.

Thanks,
M

On 8/2/05, Tom Ziemer <t....@dkfz-heidelberg.de> wrote:
> Hi,
> 
> I cannot confirm this, but my use case is slightly different. I have a
> server, that always sends exactly one attachment. During testing we have
> setup a cluster of multiple machines to access this server
> simultaneously and request binary data (which was sent as an
> attachment). The attachmentCount was always 1, as expected.
> 
> Regards,
> Tom
> 
> Axis User wrote:
> > Hi,
> > Further investigation has shown that the attachments are not in fact
> > lost but appear in a different SOAP message! e.g. if 30 clients send
> > an attachment one message will return getAttachmentCount() == 30 and
> > the other 29 messages return getAttachmentCount() == 0.
> > I have found this problem also to occur with reasonably small
> > attachments (i.e. 4k)
> >
> > This looks like a bug - can anyone comment?
> >
> > M
> >
> > On 8/1/05, Axis User <ax...@gmail.com> wrote:
> >
> >>Hi Tom,
> >>Thanks for your reply. Further to my last mail I should say that
> >>sending large attachments sequentially works fine. The problem for me
> >>arises when I have multiple clients sending in parallel (i.e.
> >>concurrent invocation of the service method) - sometimes
> >>getAttachmentCount() returns 0 other times it works fine (with your
> >>code fragment it becomes a NoSuchElement exception thrown
> >>occasionally)
> >>
> >>Have you encountered or tested this situation before?
> >>
> >>Does anyone know if Axis supports writing multiple attachments at the same time?
> >>
> >>Thanks,
> >>Michael
> >>
> >>On 8/1/05, Tom Ziemer <t....@dkfz-heidelberg.de> wrote:
> >>
> >>>Hi,
> >>>
> >>>try this:
> >>>
> >>>        DataHandler dh = null;
> >>>         Message m = context.getCurrentMessage();
> >>>         logger.info("[client]: Found attachments: "+m.countAttachments());
> >>>         Iterator it = m.getAttachments();
> >>>         while(it.hasNext())
> >>>         {
> >>>             AttachmentPart ap = (AttachmentPart)it.next();
> >>>             dh = ap.getDataHandler();
> >>>            ...
> >>>         }
> >>>
> >>>I am using Axis 1.3 (CVS) and can send (Server->Client) large files (up
> >>>to 1.2GB) without a problem.
> >>>
> >>>Hope this helps,
> >>>Regards,
> >>>Tom
> >>>
> >>>
> >>>Axis User wrote:
> >>>
> >>>>Hi,
> >>>>First some info...
> >>>>
> >>>>Platform: Axis 1.2.1, Java 1.5.0_04-b05, Linux 2.6.11.4-20a-default
> >>>>
> >>>>Aim: to send a zip file attached to a SOAP message and save it to a
> >>>>directory. Zip files will on average be around 50Mb.
> >>>>
> >>>>Code:
> >>>>//On the client side I add attachments as below:
> >>>>
> >>>>DataHandler handler = new DataHandler(new FileDataSource(file));
> >>>>stub.addAttachment(handler);
> >>>>
> >>>>//server side retrieval
> >>>>MessageContext msgContext = MessageContext.getCurrentContext();
> >>>>Message requestMessage = msgContext.getRequestMessage();
> >>>>int numAttachments = requestMessage.getAttachmentsImpl().getAttachmentCount();
> >>>>
> >>>>Problem:
> >>>>The problem seems to be to me that my service method is being invoked
> >>>>before the entire attachment has been transferred hence numAttachments
> >>>>== 0 even though the client always sends an attachment. Is there a way
> >>>>to determine that the entire message has been received before querying
> >>>>the number of attachments? In this case the attachments are ~45mb
> >>>>
> >>>>Thanks,
> >>>>Mike
> >>>
>

Re: reading large attachments

Posted by Tom Ziemer <t....@dkfz-heidelberg.de>.
Hi,

I cannot confirm this, but my use case is slightly different. I have a 
server, that always sends exactly one attachment. During testing we have 
setup a cluster of multiple machines to access this server 
simultaneously and request binary data (which was sent as an 
attachment). The attachmentCount was always 1, as expected.

Regards,
Tom

Axis User wrote:
> Hi,
> Further investigation has shown that the attachments are not in fact
> lost but appear in a different SOAP message! e.g. if 30 clients send
> an attachment one message will return getAttachmentCount() == 30 and
> the other 29 messages return getAttachmentCount() == 0.
> I have found this problem also to occur with reasonably small
> attachments (i.e. 4k)
> 
> This looks like a bug - can anyone comment?
> 
> M
> 
> On 8/1/05, Axis User <ax...@gmail.com> wrote:
> 
>>Hi Tom,
>>Thanks for your reply. Further to my last mail I should say that
>>sending large attachments sequentially works fine. The problem for me
>>arises when I have multiple clients sending in parallel (i.e.
>>concurrent invocation of the service method) - sometimes
>>getAttachmentCount() returns 0 other times it works fine (with your
>>code fragment it becomes a NoSuchElement exception thrown
>>occasionally)
>>
>>Have you encountered or tested this situation before?
>>
>>Does anyone know if Axis supports writing multiple attachments at the same time?
>>
>>Thanks,
>>Michael
>>
>>On 8/1/05, Tom Ziemer <t....@dkfz-heidelberg.de> wrote:
>>
>>>Hi,
>>>
>>>try this:
>>>
>>>        DataHandler dh = null;
>>>         Message m = context.getCurrentMessage();
>>>         logger.info("[client]: Found attachments: "+m.countAttachments());
>>>         Iterator it = m.getAttachments();
>>>         while(it.hasNext())
>>>         {
>>>             AttachmentPart ap = (AttachmentPart)it.next();
>>>             dh = ap.getDataHandler();
>>>            ...
>>>         }
>>>
>>>I am using Axis 1.3 (CVS) and can send (Server->Client) large files (up
>>>to 1.2GB) without a problem.
>>>
>>>Hope this helps,
>>>Regards,
>>>Tom
>>>
>>>
>>>Axis User wrote:
>>>
>>>>Hi,
>>>>First some info...
>>>>
>>>>Platform: Axis 1.2.1, Java 1.5.0_04-b05, Linux 2.6.11.4-20a-default
>>>>
>>>>Aim: to send a zip file attached to a SOAP message and save it to a
>>>>directory. Zip files will on average be around 50Mb.
>>>>
>>>>Code:
>>>>//On the client side I add attachments as below:
>>>>
>>>>DataHandler handler = new DataHandler(new FileDataSource(file));
>>>>stub.addAttachment(handler);
>>>>
>>>>//server side retrieval
>>>>MessageContext msgContext = MessageContext.getCurrentContext();
>>>>Message requestMessage = msgContext.getRequestMessage();
>>>>int numAttachments = requestMessage.getAttachmentsImpl().getAttachmentCount();
>>>>
>>>>Problem:
>>>>The problem seems to be to me that my service method is being invoked
>>>>before the entire attachment has been transferred hence numAttachments
>>>>== 0 even though the client always sends an attachment. Is there a way
>>>>to determine that the entire message has been received before querying
>>>>the number of attachments? In this case the attachments are ~45mb
>>>>
>>>>Thanks,
>>>>Mike
>>>

Re: reading large attachments

Posted by Axis User <ax...@gmail.com>.
Hi,
Further investigation has shown that the attachments are not in fact
lost but appear in a different SOAP message! e.g. if 30 clients send
an attachment one message will return getAttachmentCount() == 30 and
the other 29 messages return getAttachmentCount() == 0.
I have found this problem also to occur with reasonably small
attachments (i.e. 4k)

This looks like a bug - can anyone comment?

M

On 8/1/05, Axis User <ax...@gmail.com> wrote:
> Hi Tom,
> Thanks for your reply. Further to my last mail I should say that
> sending large attachments sequentially works fine. The problem for me
> arises when I have multiple clients sending in parallel (i.e.
> concurrent invocation of the service method) - sometimes
> getAttachmentCount() returns 0 other times it works fine (with your
> code fragment it becomes a NoSuchElement exception thrown
> occasionally)
> 
> Have you encountered or tested this situation before?
> 
> Does anyone know if Axis supports writing multiple attachments at the same time?
> 
> Thanks,
> Michael
> 
> On 8/1/05, Tom Ziemer <t....@dkfz-heidelberg.de> wrote:
> > Hi,
> >
> > try this:
> >
> >         DataHandler dh = null;
> >          Message m = context.getCurrentMessage();
> >          logger.info("[client]: Found attachments: "+m.countAttachments());
> >          Iterator it = m.getAttachments();
> >          while(it.hasNext())
> >          {
> >              AttachmentPart ap = (AttachmentPart)it.next();
> >              dh = ap.getDataHandler();
> >             ...
> >          }
> >
> > I am using Axis 1.3 (CVS) and can send (Server->Client) large files (up
> > to 1.2GB) without a problem.
> >
> > Hope this helps,
> > Regards,
> > Tom
> >
> >
> > Axis User wrote:
> > > Hi,
> > > First some info...
> > >
> > > Platform: Axis 1.2.1, Java 1.5.0_04-b05, Linux 2.6.11.4-20a-default
> > >
> > > Aim: to send a zip file attached to a SOAP message and save it to a
> > > directory. Zip files will on average be around 50Mb.
> > >
> > > Code:
> > > //On the client side I add attachments as below:
> > >
> > > DataHandler handler = new DataHandler(new FileDataSource(file));
> > > stub.addAttachment(handler);
> > >
> > > //server side retrieval
> > > MessageContext msgContext = MessageContext.getCurrentContext();
> > > Message requestMessage = msgContext.getRequestMessage();
> > > int numAttachments = requestMessage.getAttachmentsImpl().getAttachmentCount();
> > >
> > > Problem:
> > > The problem seems to be to me that my service method is being invoked
> > > before the entire attachment has been transferred hence numAttachments
> > > == 0 even though the client always sends an attachment. Is there a way
> > > to determine that the entire message has been received before querying
> > > the number of attachments? In this case the attachments are ~45mb
> > >
> > > Thanks,
> > > Mike
> >
>

Re: reading large attachments

Posted by Axis User <ax...@gmail.com>.
Hi Tom,
Thanks for your reply. Further to my last mail I should say that
sending large attachments sequentially works fine. The problem for me
arises when I have multiple clients sending in parallel (i.e.
concurrent invocation of the service method) - sometimes
getAttachmentCount() returns 0 other times it works fine (with your
code fragment it becomes a NoSuchElement exception thrown
occasionally)

Have you encountered or tested this situation before?

Does anyone know if Axis supports writing multiple attachments at the same time?

Thanks,
Michael

On 8/1/05, Tom Ziemer <t....@dkfz-heidelberg.de> wrote:
> Hi,
> 
> try this:
> 
>         DataHandler dh = null;
>          Message m = context.getCurrentMessage();
>          logger.info("[client]: Found attachments: "+m.countAttachments());
>          Iterator it = m.getAttachments();
>          while(it.hasNext())
>          {
>              AttachmentPart ap = (AttachmentPart)it.next();
>              dh = ap.getDataHandler();
>             ...
>          }
> 
> I am using Axis 1.3 (CVS) and can send (Server->Client) large files (up
> to 1.2GB) without a problem.
> 
> Hope this helps,
> Regards,
> Tom
> 
> 
> Axis User wrote:
> > Hi,
> > First some info...
> >
> > Platform: Axis 1.2.1, Java 1.5.0_04-b05, Linux 2.6.11.4-20a-default
> >
> > Aim: to send a zip file attached to a SOAP message and save it to a
> > directory. Zip files will on average be around 50Mb.
> >
> > Code:
> > //On the client side I add attachments as below:
> >
> > DataHandler handler = new DataHandler(new FileDataSource(file));
> > stub.addAttachment(handler);
> >
> > //server side retrieval
> > MessageContext msgContext = MessageContext.getCurrentContext();
> > Message requestMessage = msgContext.getRequestMessage();
> > int numAttachments = requestMessage.getAttachmentsImpl().getAttachmentCount();
> >
> > Problem:
> > The problem seems to be to me that my service method is being invoked
> > before the entire attachment has been transferred hence numAttachments
> > == 0 even though the client always sends an attachment. Is there a way
> > to determine that the entire message has been received before querying
> > the number of attachments? In this case the attachments are ~45mb
> >
> > Thanks,
> > Mike
>

Re: reading large attachments

Posted by Tom Ziemer <t....@dkfz-heidelberg.de>.
Hi,

try this:

	DataHandler dh = null;
         Message m = context.getCurrentMessage();
         logger.info("[client]: Found attachments: "+m.countAttachments());
         Iterator it = m.getAttachments();
         while(it.hasNext())
         {
             AttachmentPart ap = (AttachmentPart)it.next();
             dh = ap.getDataHandler();
	    ...
         }

I am using Axis 1.3 (CVS) and can send (Server->Client) large files (up 
to 1.2GB) without a problem.

Hope this helps,
Regards,
Tom


Axis User wrote:
> Hi,
> First some info...
>  
> Platform: Axis 1.2.1, Java 1.5.0_04-b05, Linux 2.6.11.4-20a-default
> 
> Aim: to send a zip file attached to a SOAP message and save it to a
> directory. Zip files will on average be around 50Mb.
> 
> Code:
> //On the client side I add attachments as below:
> 
> DataHandler handler = new DataHandler(new FileDataSource(file));
> stub.addAttachment(handler);
> 
> //server side retrieval
> MessageContext msgContext = MessageContext.getCurrentContext();
> Message requestMessage = msgContext.getRequestMessage();
> int numAttachments = requestMessage.getAttachmentsImpl().getAttachmentCount();
> 
> Problem:
> The problem seems to be to me that my service method is being invoked
> before the entire attachment has been transferred hence numAttachments
> == 0 even though the client always sends an attachment. Is there a way
> to determine that the entire message has been received before querying
> the number of attachments? In this case the attachments are ~45mb
> 
> Thanks,
> Mike