The Source for Java Technology Collaboration

Home » java.net Forums » GlassFish » Metro and JAXB

Thread: How to retrieve inputstream from StaxSource when using Provider API

Welcome, Guest Help
Login Login
Guest Settings Guest Settings
This question is not answered. Helpful answers available: 2. Correct answers available: 1.

Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 2 - Last Post: Nov 11, 2008 3:19 PM by: techiesaf
techiesaf

Posts: 20
How to retrieve inputstream from StaxSource when using Provider API
Posted: Nov 10, 2008 12:16 PM
 
  Click to reply to this thread Reply

Hi,
I need to do stream large messages that will be passed from the client to the server side - so decided to go with the provider API. However on the server side we receive a StaxSource object - and it is not possible to retrieve a stream from that object. I had to do the following in my code - but it doesnt seem like the right solution since i do not want to write out all the binary data in memory in the ByteOutputStream... Does Metro provide some way of going about it - since the whole purpose of Provider API is to enable us to handle large messages --

ByteArrayOutputStream bos = new ByteArrayOutputStream();
StreamResult streamResult = new StreamResult(bos);
Transformer trans = TransformerFactory.newInstance().newTransformer();
trans.transform(inSource, streamResult);
bos.close();
ByteArrayInputStream in = new ByteArrayInputStream(bos.toByteArray());


thanks.

Fabian Ritzmann
Re: How to retrieve inputstream from StaxSource when using Provider API
Posted: Nov 11, 2008 4:28 AM   in response to: techiesaf
  Click to reply to this thread Reply

On 10. Nov 2008, at 22:16, metro@javadesktop.org wrote:

> I need to do stream large messages that will be passed from the
> client to the server side - so decided to go with the provider API.
> However on the server side we receive a StaxSource object - and it
> is not possible to retrieve a stream from that object. I had to do
> the following in my code - but it doesnt seem like the right
> solution since i do not want to write out all the binary data in
> memory in the ByteOutputStream... Does Metro provide some way of
> going about it - since the whole purpose of Provider API is to
> enable us to handle large messages --
>
> ByteArrayOutputStream bos = new ByteArrayOutputStream();
> StreamResult streamResult = new StreamResult(bos);
> Transformer trans =
> TransformerFactory.newInstance().newTransformer();
> trans.transform(inSource, streamResult);
> bos.close();
> ByteArrayInputStream in = new
> ByteArrayInputStream(bos.toByteArray());

Are you aware of this:
https://metro.dev.java.net/guide/Large_Attachments.html

Fabian

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@metro.dev.java.net
For additional commands, e-mail: users-help@metro.dev.java.net


techiesaf

Posts: 20
Re: How to retrieve inputstream from StaxSource when using Provider API
Posted: Nov 11, 2008 3:19 PM   in response to: Fabian Ritzmann
 
  Click to reply to this thread Reply

Hi Fabian,
Thanks, I will look into Mtoms to see if that will resolve my issue.
SA




 XML java.net RSS