Fran To get the data out of a DataHandler, you need to understand the InputStream model in Java.
http://java.sun.com/j2se/1.4.2/docs/api/java/io/InputStream.html Basically, if you can allocate a buffer big enough to get all the data its easy. Suppose you know you are only going to get less than 1000 bytes: byte buf[] = new byte[1000]; int bytesActuallyRead = dh.getDataSource().getInputStream().read(buf); If you don't know how big the file is you have to loop through it. Paul On 5/21/07, Fran <[EMAIL PROTECTED]> wrote:
2007/5/21, Paul Fremantle <[EMAIL PROTECTED]>: > No problem! > > The DataHandler is an abstraction over a byte array or file. The > reason is that you might have a very large binary data object (maybe a > file) and you don't want to load the whole thing into memory. The > DataHandler object lets Axis2 stream such large objects straight from > file to the network without having to load the whole byte[] in memory > at once. > > But in your case I'm guessing its ok to have a byte[], so here is what > you need to do. > > To create a DataHandler from a byte[], just do: > > import org.apache.axiom.attachments.ByteArrayDataSource; > > DataHandler dh = new DataHandler(new ByteArrayDataSource(yourByteArray)) > And to get the content of a DataHandler into a byte array? > Alternatively, if you know the data type of the binary data (e.g. > image), you can mark up the schema using > > <element name="MyBinaryData" > xmime:expectedContentTypes='image/jpeg' type="xmime:base64Binary"/> > > This will trigger the ADB databinding tool to recognize this as an > image and map it into a java.awt.Image. > > Its worth reading: http://ws.apache.org/axis2/1_2/mtom-guide.html > > Paul > > On 5/21/07, Fran <[EMAIL PROTECTED]> wrote: > > Hi! > > > > I've got a web service that send/receive byte[] in some methods, I'm > > using ADB and I have done a WSDL and Skeleton for my service, but I > > don't know how get/set byte[] in the parameters of my methods, I see > > that byte[] is transformed in DataHandler but I don't know how to > > interact with DataHandler. > > > > Can anyone help me? > > > > Thanks! > > > > PS: Sorry for my poor English. > > > > -- > > Saludos > > > > Fran > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > -- > Paul Fremantle > VP/Technology, WSO2 and OASIS WS-RX TC Co-chair > > http://bloglines.com/blog/paulfremantle > [EMAIL PROTECTED] > > "Oxygenating the Web Service Platform", www.wso2.com > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Saludos Fran --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
-- Paul Fremantle VP/Technology, WSO2 and OASIS WS-RX TC Co-chair http://bloglines.com/blog/paulfremantle [EMAIL PROTECTED] "Oxygenating the Web Service Platform", www.wso2.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
