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