Hi Leo

Thanks for the issue information. What if we set the content type used when writing the message as a JMS header to the text message? do you think this will solve the problem? Also could you attach the stack trace for the error you receive

Currently I have performed quite a few enhancements to the JMS transport here (http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/transports/) but have not yet checked these into the Axis2 SVN as I haven't completed testing on this (or released Synapse which depends on this code). I am planning to merge these changes around early November back to Axis2

asankha

Leo Huber (JIRA) wrote:
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;
    }


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

Reply via email to