[ 
https://issues.apache.org/jira/browse/CXF-1668?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12622364#action_12622364
 ] 

Christian Schneider commented on CXF-1668:
------------------------------------------

Basically this sounds good to me but what I do not understand is how JMS 
handles TextMessages internally. When I create a TextMessage from a string in 
System A how is this message then encoded on the wire? And how is it then 
decoded into a string in System B again. While we stay in Java this is trivial 
as Java always uses Unicode internally. But what happens when I create JMS 
Messages in other Languages like C# or C? Does the System encoding influence 
the behaviour?

I would like to implement the modified Stax Interceptors. Can you give me some 
clues what is to be done. I guess I have to first set the message content in 
JMSConduit.receiveMessage as:

            if (response instanceof String) {
                inMessage.setContent(StringReader.class, new 
StringReader(response));
            } else {
                byte[] bytes = (byte[])response;
                inMessage.setContent(InputStream.class, new 
ByteArrayInputStream(bytes));
            }

Is this correct or should I rather use a StringReader in both cases and do the 
decoding of byte[] at this point ? I guess the second could be problematic if 
the content is not XML.

But what do I have to do in the interceptor?


> Wrong encoding using JMS Transport
> ----------------------------------
>
>                 Key: CXF-1668
>                 URL: https://issues.apache.org/jira/browse/CXF-1668
>             Project: CXF
>          Issue Type: Bug
>          Components: Transports
>    Affects Versions: 2.1
>         Environment: MS Windows XP, Sun Solaris
>            Reporter: Eduard Hildebrandt
>
> In class JMSConduit getBytes() is used to transform the string in a byte 
> array.
>             byte[] bytes = null;
>             if (response instanceof String) {
>                 String requestString = (String)response;                
>                 bytes = requestString.getBytes();
>             } else {
>                 bytes = (byte[])response;
>             }
> getBytes() uses the standard encoding of the plattform. This is wrong because 
> the encoding of the message must be used.
> I have written an interceptor as workaround to solve this issue:
> public class EncodingInterceptor extends AbstractPhaseInterceptor<Message> {
>     public EncodingInterceptor() {
>         super(Phase.RECEIVE);
>     }
>     public void handleMessage(Message message) {   
>       try {
>               InputStream inputStream = message.getContent(InputStream.class);
>               ByteArrayOutputStream baos = new ByteArrayOutputStream();       
>               while (true) {
>                       int datum = inputStream.read();
>                       if (datum == -1)
>                               break;
>                       baos.write(datum);
>               }        
>               String string = baos.toString();
>               ByteArrayInputStream bais = new 
> ByteArrayInputStream(string.getBytes("UTF-8"));
>               message.setContent(InputStream.class, bais);
>               } catch (IOException e) {
>                       e.printStackTrace();
>               }
>     }
>     public void handleFault(Message messageParam) {
>     }
> }
> But the issue should be solved in JMSConduit class.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to