Yes, this is expected behavior.  All attachments are deserialized as DataHandler.

Scott Nichol

Do not send e-mail directly to this e-mail address,
because it is filtered to accept only mail from
specific mail lists.
----- Original Message ----- 
From: "Praveen Peddi" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, December 29, 2003 10:20 AM
Subject: Re: Sending response as stream


> Hi Scott,
> Even after sending the response as InputStream on the server side, its
> coming as DataHandler on the client side. When I cast the return value to
> InputStream, it was throwing ClassCastException. I printed the class name
> its coming as DataHandler.
> Its ok in my case but just wanted to make sure that its an expected
> behaviour on the client side.
> 
> Praveen
> 
> ----- Original Message ----- 
> From: "Scott Nichol" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Monday, December 22, 2003 5:42 PM
> Subject: Re: Sending response as stream
> 
> 
> The one advantage I can think of with DataHandler is that you can specify
> the MIME type.  For an InputStream, the MIME type is always
> "application/octet-stream".
> 
> Yes, you can use an InputStream when specifying an attachment as a method
> parameter as well.
> 
> Scott Nichol
> 
> Do not send e-mail directly to this e-mail address,
> because it is filtered to accept only mail from
> specific mail lists.
> ----- Original Message ----- 
> From: "Praveen Peddi" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Monday, December 22, 2003 5:29 PM
> Subject: Re: Sending response as stream
> 
> 
> > Can I do the same thing if I want to send data as attachment. For example
> > upload file. The examples I saw are buidling DataHandler. What exactly is
> > the advantage of using a DataHandler compared to sending just an
> > inputstream. If there is no difference, atleast the code will be
> independent
> > of soap api.
> >
> > Praveen
> >
> > ----- Original Message ----- 
> > From: "Scott Nichol" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Monday, December 22, 2003 4:48 PM
> > Subject: Re: Sending response as stream
> >
> >
> > Or, you can add a mapping in your deployment descriptor to specify
> > MimePartSerializer as the serializer for a ByteArrayInputStream.
> >
> > Scott Nichol
> >
> > Do not send e-mail directly to this e-mail address,
> > because it is filtered to accept only mail from
> > specific mail lists.
> > ----- Original Message ----- 
> > From: "Scott Nichol" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Monday, December 22, 2003 4:40 PM
> > Subject: Re: Sending response as stream
> >
> >
> > Is your method declared to return a ByteArrayInputStream?  It should be
> > declared to return an InputStream.
> >
> > Scott Nichol
> >
> > Do not send e-mail directly to this e-mail address,
> > because it is filtered to accept only mail from
> > specific mail lists.
> > ----- Original Message ----- 
> > From: "Praveen Peddi" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Monday, December 22, 2003 2:59 PM
> > Subject: Re: Sending response as stream
> >
> >
> > > I tried this and I got the following error:
> > > No Serializer found to serialize a java.io.ByteArrayInputStream'
> > >
> > > Do I have to write a serializer for ByteArrayInputStream?
> > >
> > > Praveen
> > >
> > > ----- Original Message ----- 
> > > From: "Scott Nichol" <[EMAIL PROTECTED]>
> > > To: <[EMAIL PROTECTED]>
> > > Sent: Monday, December 22, 2003 2:42 PM
> > > Subject: Re: Sending response as stream
> > >
> > >
> > > As I said, or at least implied, in a prior posting, I believe you can
> > return
> > > an InputStream from your method, and its contents will be serialized as
> an
> > > attachment.  Have you tried that?  It would be something like
> > >
> > >  byte [] returnBytes = null;
> > >  ByteArrayOutputStream out = new ByteArrayOutputStream();
> > >  ObjectOutputStream s;
> > >    try {
> > >     s = new ObjectOutputStream(out);
> > >     s.writeObject(objects);
> > >     s.flush();
> > >     returnBytes = out.toByteArray();
> > >     objects = null;
> > >     log.debug("SIZE OF THE RETURNING BYTES:"+returnBytes.length);
> > >     return new ByteArrayInputStream(returnBytes);
> > >    } catch (Throwable ex) {
> > >     log.error("Unable to serialize the object list.", ex);
> > >     throw new
> > SearchException(ISearchResourceKeys.UNABLE_TO_COMPLETE_QUERY,
> > >      ex);
> > >    }
> > >
> > > Scott Nichol
> > >
> > > Do not send e-mail directly to this e-mail address,
> > > because it is filtered to accept only mail from
> > > specific mail lists.
> > > ----- Original Message ----- 
> > > From: "Praveen Peddi" <[EMAIL PROTECTED]>
> > > To: <[EMAIL PROTECTED]>
> > > Sent: Monday, December 22, 2003 10:17 AM
> > > Subject: Re: Sending response as stream
> > >
> > >
> > > > I serialized the List to byte[] and sent it as attachment
> (DataHandler).
> > > But
> > > > I had to use soap specific class on my server side. As I mentioned in
> my
> > > > previous email our soap services are transparent from our soap tool so
> > > far.
> > > > But with this attachment stuff, I had to use some soap specifc
> classes.
> > > > Following is the code I used to build DataHandler.
> > > >
> > > > byte [] returnBytes = null;
> > > >   ByteArrayOutputStream out = new ByteArrayOutputStream();
> > > >   ObjectOutputStream s;
> > > >   try {
> > > >    s = new ObjectOutputStream(out);
> > > >    s.writeObject(objects);
> > > >    s.flush();
> > > >    returnBytes = out.toByteArray();
> > > >    objects = null;
> > > >    log.debug("SIZE OF THE RETURNING BYTES:"+returnBytes.length);
> > > >    DataSource ds = new ByteArrayDataSource(returnBytes,
> > > >          "application/octet-stream");
> > > >    dh = new DataHandler(ds);
> > > >   } catch (Throwable ex) {
> > > >    log.error("Unable to serialize the object list.", ex);
> > > >    throw new
> > SearchException(ISearchResourceKeys.UNABLE_TO_COMPLETE_QUERY,
> > > >     ex);
> > > >   }
> > > >
> > > > Is there anyway I can the above code so I don't have to use
> > > > org.apache.soap.util.mime.ByteArrayDataSource to build the
> DataHandler?
> > > >
> > > >
> > > > Praveen
> > > >
> > > > ---- Original Message ----- 
> > > > From: "Scott Nichol" <[EMAIL PROTECTED]>
> > > > To: <[EMAIL PROTECTED]>
> > > > Sent: Friday, December 19, 2003 3:51 PM
> > > > Subject: Re: Sending response as stream
> > > >
> > > >
> > > > Looking at SOAPMappingRegistry, the following classes are all
> serialized
> > > as
> > > > attachments.
> > > >
> > > >    javax.mail.internet.MimeBodyPart.class,
> > > >    java.io.InputStream.class,
> > > >    javax.activation.DataSource.class,
> > > >    javax.activation.DataHandler.class,
> > > >
> > > > If your method returns your List as, say, an InputStream, I believe
> you
> > > will
> > > > find its contents are included as an attachment.
> > > >
> > > > One thing to watch out for with attachments.  Last time I looked, .NET
> > > only
> > > > supported DIME attachments.  The SOAP Attachments specs (which MSFT
> > > > co-authored) calls for MIME attachments, which is what Apache SOAP
> uses.
> > > >
> > > > Scott Nichol
> > > >
> > > > Do not send e-mail directly to this e-mail address,
> > > > because it is filtered to accept only mail from
> > > > specific mail lists.
> > > > ----- Original Message ----- 
> > > > From: "Praveen Peddi" <[EMAIL PROTECTED]>
> > > > To: <[EMAIL PROTECTED]>
> > > > Sent: Friday, December 19, 2003 11:31 AM
> > > > Subject: Re: Sending response as stream
> > > >
> > > >
> > > > > Hello all,
> > > > > Is there a way a method in a soap service can return an object
> > > > > (java.util.List) as attachment with out using soap specific classes.
> > > > > I was looking at the mime example in soap samples and it was using
> > > > > ByteArrayDatasource which is soap specific class.
> > > > > The example I saw looked like this:
> > > > > DataSource ds = new ByteArrayDataSource(new File(fname[i]), null);
> > > > >
> > > > > I think my question probably is "Is there any way to build a
> > DataHandler
> > > > > object w/o using apache soap tool on the server side?"
> > > > >
> > > > > I am trying send the java.util.List as an attachment. the list has
> > > strings
> > > > > in it. The reason I want to send it as attachment is because the
> list
> > > has
> > > > > 1000s of strings and sending it as List will fillup the soap envelop
> > and
> > > > > putting overhead of parsing the huge xml which in turn is filling up
> > all
> > > > my
> > > > > memory with the parsed document. If I send the same list as an
> > > attchment,
> > > > I
> > > > > am assuming that I will not have this problem. The size of the list
> > > itself
> > > > > is not a problem I think. Its the size of the soap envelop thats
> > killing
> > > > the
> > > > > app.
> > > > >
> > > > > Am I right?
> > > > >
> > > > > The reason I do not want to use soap specific classes is because our
> > > soap
> > > > > services are plain java classes and designed such a way that we can
> > > swith
> > > > to
> > > > > any soap tool in the future.
> > > > >
> > > > > Thanks.
> > > > >
> > > > > Praveen
> > > > >
> > > > > ----- Original Message ----- 
> > > > > From: "Martin Gainty" <[EMAIL PROTECTED]>
> > > > > To: <[EMAIL PROTECTED]>
> > > > > Sent: Wednesday, December 17, 2003 1:15 AM
> > > > > Subject: Re: Sending response as stream
> > > > >
> > > > >
> > > > > > Read this
> > > > > > http://www.w3.org/2000/xp/Group/2/07/SOAP-AF/aftf-soap-af.html
> > > > > > Regards,
> > > > > > Martin
> > > > > > ----- Original Message ----- 
> > > > > > From: "Praveen Peddi" <[EMAIL PROTECTED]>
> > > > > > To: <[EMAIL PROTECTED]>
> > > > > > Sent: Tuesday, December 16, 2003 11:32 AM
> > > > > > Subject: Re: Sending response as stream
> > > > > >
> > > > > >
> > > > > > > Does it mean that attachments are sent as streams and not part
> of
> > > soap
> > > > > > > envelop?
> > > > > > >
> > > > > > > I think my problem here is the memory and time. So If I send it
> as
> > > > > > > attachment, the client can read the stream and may be save it to
> > > disk
> > > > > > rather
> > > > > > > than filling the memory?
> > > > > > >
> > > > > > > Praveen
> > > > > > >
> > > > > > > ----- Original Message ----- 
> > > > > > > From: "Scott Nichol" <[EMAIL PROTECTED]>
> > > > > > > To: <[EMAIL PROTECTED]>
> > > > > > > Sent: Tuesday, December 16, 2003 10:54 AM
> > > > > > > Subject: Re: Sending response as stream
> > > > > > >
> > > > > > >
> > > > > > > Attachments are the one way I can think of to minimize the
> > > processing
> > > > > > Apache
> > > > > > > SOAP will do.
> > > > > > >
> > > > > > > Scott Nichol
> > > > > > >
> > > > > > > Do not send e-mail directly to this e-mail address,
> > > > > > > because it is filtered to accept only mail from
> > > > > > > specific mail lists.
> > > > > > > ----- Original Message ----- 
> > > > > > > From: "Praveen Peddi" <[EMAIL PROTECTED]>
> > > > > > > To: <[EMAIL PROTECTED]>
> > > > > > > Sent: Tuesday, December 16, 2003 10:30 AM
> > > > > > > Subject: Sending response as stream
> > > > > > >
> > > > > > >
> > > > > > > HI all,
> > > > > > > We are using apache soap both on serverside and on client side.
> > > > > > > I am trying to write a method in soap service that returns
> > thousands
> > > > of
> > > > > > > objects that are converted into xml elements. Returning the
> whole
> > > > > response
> > > > > > > as an xml string is taking for ever. I am wondering if I can
> send
> > > the
> > > > > > > response as an output stream rather than as xml string.
> > > > > > >
> > > > > > > How about sending the response as attachment. Will it do any
> > better.
> > > I
> > > > > > think
> > > > > > > attachments are sent as streams if I am not wrong.
> > > > > > >
> > > > > > > Thanks
> > > > > > > Praveen
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
> >
> 
>

Reply via email to