Encoding of text messages using SOAP over JMS
---------------------------------------------

                 Key: AXIS2-3238
                 URL: https://issues.apache.org/jira/browse/AXIS2-3238
             Project: Axis 2.0 (Axis2)
          Issue Type: Bug
            Reporter: Leo Huber


Hi,

I am new to axis2 and jms. We are sending soap messages over JMS textmessages. 
We are struggling with a encoding issue and 
I tried to find the source of the problem. I found that the class JMSSender 
handles receiving jms text messages like any other message and creates a 
bytestream using the getInputStream method in JMSUtils. However, the bytestream 
is either encoded with the encoding set in 
the message or with the default encoding of the operating system (see the copy 
of the method below). Later this bytestream is
used to create a SOAP Message object using the encoding set in 
"Constants.Configuration.CONTENT_TYPE". This leads to an encoding
issue if the encoding used to create the byte stream and the encoding to read 
the byte stream (create the soap message)
are not the same. 

We are developing on windows machines but are testing on linux machines which 
both have different default encoding set in the jvm. Therefore, because of the 
behaviour described above axis2 behaves differently on linux and windows. 
However, I don't see why axis creates a byte stream with a possibly different 
encoding
than creating the soap message with that stream.

Regards
Leo



/**
     * Get an InputStream to the message
     *
     * @param message the JMS message
     * @return an InputStream
     */
    public static InputStream getInputStream(Message message) {

        try {
            // get the incoming msg content into a byte array
            if (message instanceof BytesMessage) {
                byte[] buffer = new byte[8 * 1024];
                ByteArrayOutputStream out = new ByteArrayOutputStream();

                BytesMessage byteMsg = (BytesMessage) message;
                for (int bytesRead = byteMsg.readBytes(buffer); bytesRead != -1;
                     bytesRead = byteMsg.readBytes(buffer)) {
                    out.write(buffer, 0, bytesRead);
                }
                return new ByteArrayInputStream(out.toByteArray());

            } else if (message instanceof TextMessage) {
                TextMessage txtMsg = (TextMessage) message;
                String contentType = 
message.getStringProperty(JMSConstants.CONTENT_TYPE);
                if (contentType != null) {
                    return
                            new ByteArrayInputStream(
                                    txtMsg.getText().getBytes(
                                            
BuilderUtil.getCharSetEncoding(contentType)));
                } else {
                    return
                            new 
ByteArrayInputStream(txtMsg.getText().getBytes());
                }

            } else {
                handleException("Unsupported JMS message type : " +
                        message.getClass().getName());
            }


        } catch (JMSException e) {
            handleException("JMS Exception getting InputStream into message", 
e);
        } catch (UnsupportedEncodingException e) {
            handleException("Encoding exception getting InputStream into 
message", e);
        }
        return null;
    }

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


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to