You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@servicemix.apache.org by Sathyashankar <sa...@nsn.com> on 2008/05/05 15:20:00 UTC

Streamsource to Stringsource

Hi,
I need to convert Streamsource to stringsource/bytessource.
The casting works fine at compile time, but throws a "Cannot cast" exception
at runtime...
Any suggestions???
Thanks in advance.
-- 
View this message in context: http://www.nabble.com/Streamsource-to-Stringsource-tp17061479p17061479.html
Sent from the ServiceMix - Dev mailing list archive at Nabble.com.


RE: Streamsource to Stringsource

Posted by ra...@wipro.com.
you can directly get the InputStream from StreamSource
 
use the following
 
Source source = in.getContent();
InputStream is=
new SourceTransformer().toStreamSource(source).getInputStream();

________________________________

From: Sathyashankar [mailto:sathya.k_a@nsn.com]
Sent: Tue 5/6/2008 11:13 AM
To: dev@servicemix.apache.org
Subject: Re: Streamsource to Stringsource




Hi gnodet,

Many Thanks for the reply.
My problem is that, i need to extract the Inputstream from Streamsouce.
The piece of code, used is :

Source source = in.getContent();   ( "in" is the Normalised in message).

SourceTransformer sourceTransformer = new SourceTransformer();
Document xml = sourceTransformer.toDOMDocument(source);

StreamSource stSource = (StreamSource )source ;
InputStream inStream = stSource.getInputStream();

The problem with this code is that, i'm getting java.io.IOException:Stream
closed.

I tried the solution, which u suggested yesterday, but getting the same
exception.

Cheers,
Sathya.




gnodet wrote:
>
> Try using the org.apache.servicemix.jbi.jaxp.SourceTransformer class.
>    Source newSource = new StringSource(new
> SourceTransformer().toString(oldSource));
>
>
> On Mon, May 5, 2008 at 3:20 PM, Sathyashankar <sa...@nsn.com> wrote:
>>
>>  Hi,
>>  I need to convert Streamsource to stringsource/bytessource.
>>  The casting works fine at compile time, but throws a "Cannot cast"
>> exception
>>  at runtime...
>>  Any suggestions???
>>  Thanks in advance.
>>  --
>>  View this message in context:
>> http://www.nabble.com/Streamsource-to-Stringsource-tp17061479p17061479.html
>>  Sent from the ServiceMix - Dev mailing list archive at Nabble.com.
>>
>>
>
>
>
> --
> Cheers,
> Guillaume Nodet
> ------------------------
> Blog: http://gnodet.blogspot.com/
>
>

--
View this message in context: http://www.nabble.com/Streamsource-to-Stringsource-tp17061479p17071596.html
Sent from the ServiceMix - Dev mailing list archive at Nabble.com.




Please do not print this email unless it is absolutely necessary. 

The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. 

WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. 

www.wipro.com

Re: Streamsource to Stringsource

Posted by Sathyashankar <sa...@nsn.com>.
Hi gnodet,

Many Thanks for the reply.
My problem is that, i need to extract the Inputstream from Streamsouce.
The piece of code, used is :

Source source = in.getContent();   ( "in" is the Normalised in message).

SourceTransformer sourceTransformer = new SourceTransformer();
Document xml = sourceTransformer.toDOMDocument(source);

StreamSource stSource = (StreamSource )source ;
InputStream inStream = stSource.getInputStream();

The problem with this code is that, i'm getting java.io.IOException:Stream
closed.

I tried the solution, which u suggested yesterday, but getting the same
exception.

Cheers,
Sathya.




gnodet wrote:
> 
> Try using the org.apache.servicemix.jbi.jaxp.SourceTransformer class.
>    Source newSource = new StringSource(new
> SourceTransformer().toString(oldSource));
> 
> 
> On Mon, May 5, 2008 at 3:20 PM, Sathyashankar <sa...@nsn.com> wrote:
>>
>>  Hi,
>>  I need to convert Streamsource to stringsource/bytessource.
>>  The casting works fine at compile time, but throws a "Cannot cast"
>> exception
>>  at runtime...
>>  Any suggestions???
>>  Thanks in advance.
>>  --
>>  View this message in context:
>> http://www.nabble.com/Streamsource-to-Stringsource-tp17061479p17061479.html
>>  Sent from the ServiceMix - Dev mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> Cheers,
> Guillaume Nodet
> ------------------------
> Blog: http://gnodet.blogspot.com/
> 
> 

-- 
View this message in context: http://www.nabble.com/Streamsource-to-Stringsource-tp17061479p17071596.html
Sent from the ServiceMix - Dev mailing list archive at Nabble.com.


Re: Streamsource to Stringsource

Posted by Guillaume Nodet <gn...@gmail.com>.
Try using the org.apache.servicemix.jbi.jaxp.SourceTransformer class.
   Source newSource = new StringSource(new
SourceTransformer().toString(oldSource));


On Mon, May 5, 2008 at 3:20 PM, Sathyashankar <sa...@nsn.com> wrote:
>
>  Hi,
>  I need to convert Streamsource to stringsource/bytessource.
>  The casting works fine at compile time, but throws a "Cannot cast" exception
>  at runtime...
>  Any suggestions???
>  Thanks in advance.
>  --
>  View this message in context: http://www.nabble.com/Streamsource-to-Stringsource-tp17061479p17061479.html
>  Sent from the ServiceMix - Dev mailing list archive at Nabble.com.
>
>



-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/