Georgi

The DataHandler is a wrapper around any type of data source. Its
documented here:
http://java.sun.com/j2ee/1.4/docs/api/javax/activation/DataHandler.html

We provide (in Axiom) a DataSource that works with an existing byte[]:
So if you have byte[] bytes you can just do:

import javax.activation.DataHandler;
import org.apache.axiom.attachments.ByteArrayDataSource;

DataHandler dh = new DataHandler(new ByteArrayDataSource(bytes));

If your POJO exposes the DataHandler, instead of the bytes, it will
still map to xs:base64Binary but it can be used more efficiently.

That doesn't get you a lot because you still have the bytes in memory
- so if this is very large (many Mb or even Gb) you will run out of
heap.

However, if the data is on disk you can use:
http://java.sun.com/j2ee/1.4/docs/api/javax/activation/FileDataSource.html

And now Axis2 can directly stream the data off the disk onto the wire
- pretty cool huh?

Paul




On 7/26/07, Georgi Yonchev <[EMAIL PROTECTED]> wrote:
> Thilina Gunarathne wrote:
> > Looks like a bug... Please report a JIRA...
> >
> > You may also try replacing byte[] with javax.activation.DataHandler...
> > DataHandler is the recommended way when using large attachments...
> >
> > thanks,
> > Thilina
> >
> > On 7/24/07, Georgi Yonchev <[EMAIL PROTECTED]> wrote:
> >> Thilina Gunarathne wrote:
> >> >> and Deepal, yes works fine, but try it with larger byte[] size,
> >> >> with larger, in the payload goes array from bytes ?!
> >> >> not encoded in base64 ..
> >> > Not clear what you meant?... Do they go as native binary in the form
> >> > of an attachment or inside the soap body...
> >> >
> >> > Thanks,
> >> > Thilina
> >> >
> >> > ---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> >> > For additional commands, e-mail: [EMAIL PROTECTED]
> >> >
> >> inside in the soap body, the bytes are not encoded in base64, is
> >> represented like integers
> >> this is a part of the xml :
> >>
> >> <ns:byteData>9</ns:byteData><ns:byteData>102</ns:byteData><ns:byteData>111</ns:byteData><ns:byteData>110</ns:byteData><ns:byteData>116</ns:byteData><ns:byteData>45</ns:byteData><ns:byteData>115</ns:byteData><ns:byteData>105</ns:byteData><ns:byteData>122</ns:byteData><ns:byteData>101</ns:byteData><ns:byteData>58</ns:byteData><ns:byteData>32</ns:byteData><ns:byteData>49</ns:byteData><ns:byteData>48</ns:byteData
> >>
> >> ><ns:byteData>112</ns:byteData><ns:byteData>116</ns:byteData><ns:byteData>59</ns:byteData><ns:byteData>13</ns:byteData><ns:byteData>10</ns:byteData><ns:byteData>9</ns:byteData><ns:byteData>102</ns:byteData><ns:byteData>111</ns:byteData><ns:byteData>110</ns:byteData><ns:byteData>116</ns:byteData><ns:byteData>45</ns:byteData><ns:byteData>119</ns:byteData><ns:byteData>101</ns:byteData><ns:byteData>105</ns:byteData><ns:byteData>103</ns:byteData><ns:byteData>104</ns:byteData><ns:byteData>116</ns:byteData><ns:byteData>58</ns:byteData><ns:byteData>32</ns:byteData><ns:byteData>110</ns:byteData><ns:byteData>111</ns:byteData><ns:byteData>114</ns:byteData><ns:byteData>109</ns:byteData><ns:byteData>97</ns:byteData><ns:byteData>108</ns:byteData><ns:byteData>59</ns:byteData><ns:byteData>13</ns:byteData><ns:byteData>10</ns:byteData><ns:byteData>125</ns:byteData><ns:byteData>13</ns:byteData><ns:byteData>10</ns:byteData><ns:byteData>46</ns:byteData><ns:byteData>99</ns:byteData><ns:byteData>111</ns:byteData><ns:byteData>110</n
> >>
> >> s:byteData><ns:byteData
> >>
> >> 2000
> >>
> >> >116</ns:byteData><ns:byteData>101</ns:byteData><ns:byteData>110</ns:byteData>
> >>
> >>
> >> this happens only when i set the byte[] in Complex return object
> >>
> >> class Result{
> >>     private byte[] bytes;
> >>     set..
> >>     get..
> >> }
> >>
> >> and the call likes:
> >> public Res test(){
> >>     ..set byte[] in res
> >>     return res;
> >> }
> >>
> >> if the call is :
> >> public byte[] test(){
> >>     ..
> >> }
> >> everything goes well...
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >> For additional commands, e-mail: [EMAIL PROTECTED]
> >>
> >>
> >
> >
> Hi Thilina,
> i report it on JIRA, and is fixed on both tags/branches in the svn...
> can you give some hints about this DataHandler ...
> some example how to implement it,
>
> 10x a lot in advance :)
> George
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


-- 
Paul Fremantle
Co-Founder and VP of Technical Sales, WSO2
OASIS WS-RX TC Co-chair

blog: http://pzf.fremantle.org
[EMAIL PROTECTED]

"Oxygenating the Web Service Platform", www.wso2.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to