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 Styrman Igor <Ig...@fi.fujitsu.com> on 2007/07/12 11:22:11 UTC

MTOM attachment handling

Hi,

I'm using Axis2. I was wondering if you dont turn on the automatic
attachment cache, does this affect how the mtom binary stream is handled
by Axis? I mean does it maybe hold reading the MIME parts until user
appoints a stream to write this data  to or does it cache the whole
thing to memory?

Not sure if it matters, but in my wsdl from which all the classes are
generated from there is a custom complex type which holds some normal
types such as s:string / s:int and then the s:b64binary. There is no
seperate wrapper element for the binary as i think i saw in a example. I
access the data through a DataHandler.

Thanks,

Igor



Re: MTOM attachment handling

Posted by Thilina Gunarathne <cs...@gmail.com>.
> > From my skeleton impl:
> > FileOutputStream fos = new FileOutputStream(file);
> > "MTOMrequest.getDataHandler()".writeTo(fos);
> > So what happens here, will I actually be writing the data to disk a
> second
> > time?
> In this case yes,
Yes... If your use case is to save the attachment to a file, then you
can directly access the cached file and move it to the appropriate
location..
            DataHandler dataHandler = MTOMrequest.getDataHandler()
            DataSource dataSource=dataHandler.getDataSource();
          // For added safety.. You can get rid of this if you specify
the caching threshold as 0.
            if (dataSource instanceof FileDataSource) {
                FileDataSource fileDataSource = (FileDataSource) dataSource;
                File file =fileDataSource.getFile();
            }

>it would be a bad idea having enabled the file-cache
> in axis2.xml.
You can specify a larger threshold for file caching to avoid smaller
attachments getting cached..  You can disable caching If you are not
planning to receive large attachments..But the danger is you would get
a outofmemory if you receive a larger one in case. ...

Thanks,
Thilina

>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>


-- 
Thilina Gunarathne  -  http://www.wso2.com - http://thilinag.blogspot.com

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


RE: MTOM attachment handling

Posted by Styrman Igor <Ig...@fi.fujitsu.com>.
To answer my own question:
requestObject."getDatahandler()".getName() --> name of cache file.

Using the xsd:base64Binary and resulting axis mapped DataHandler -object
seems to work fine.

> From my skeleton impl:
> FileOutputStream fos = new FileOutputStream(file);
> "MTOMrequest.getDataHandler()".writeTo(fos);
> So what happens here, will I actually be writing the data to disk a
second
> time?
In this case yes, it would be a bad idea having enabled the file-cache
in axis2.xml.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


RE: MTOM attachment handling

Posted by Styrman Igor <Ig...@fi.fujitsu.com>.
Thanks for your help.

How to get a handle to Axis' file cache, to the current file especially. Is the cache file guaranteed to have been fully written and closed when my service skeleton implementation code will be run? 

>From my skeleton impl:
FileOutputStream fos = new FileOutputStream(file);
"MTOMrequest.getDataHandler()".writeTo(fos);
So what happens here, will I actually be writing the data to disk a second time?

> -----Original Message-----
> From: Thilina Gunarathne [mailto:csethil@gmail.com]
> Sent: 12. heinäkuuta 2007 12:52
> To: axis-user@ws.apache.org
> Subject: Re: MTOM attachment handling
> 
> > I'm using Axis2. I was wondering if you dont turn on the automatic
> > attachment cache, does this affect how the mtom binary stream is handled
> by
> > Axis?
> Not much...If it's enabled the attachment will be cached in a file, if
> not it'll be cached in memory..
> > I mean does it maybe hold reading the MIME parts until user appoints a
> > stream to write this data  to or does it cache the whole thing to
> memory?
> In to memory..
> 
> > Not sure if it matters, but in my wsdl from which all the classes are
> > generated from there is a custom complex type which holds some normal
> types
> > such as s:string / s:int and then the s:b64binary. There is no seperate
> > wrapper element for the binary as i think i saw in a example. I access
> the
> > data through a DataHandler.
> Are you facing any problems with this combination..
> 
> thanks,
> Thilina
> >
> > Thanks,
> >
> > Igor
> >
> 
> 
> --
> Thilina Gunarathne  -  http://www.wso2.com - http://thilinag.blogspot.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: MTOM attachment handling

Posted by Thilina Gunarathne <cs...@gmail.com>.
> I'm using Axis2. I was wondering if you dont turn on the automatic
> attachment cache, does this affect how the mtom binary stream is handled by
> Axis?
Not much...If it's enabled the attachment will be cached in a file, if
not it'll be cached in memory..
> I mean does it maybe hold reading the MIME parts until user appoints a
> stream to write this data  to or does it cache the whole thing to memory?
In to memory..

> Not sure if it matters, but in my wsdl from which all the classes are
> generated from there is a custom complex type which holds some normal types
> such as s:string / s:int and then the s:b64binary. There is no seperate
> wrapper element for the binary as i think i saw in a example. I access the
> data through a DataHandler.
Are you facing any problems with this combination..

thanks,
Thilina
>
> Thanks,
>
> Igor
>


-- 
Thilina Gunarathne  -  http://www.wso2.com - http://thilinag.blogspot.com

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org