You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by "Leo Huber (JIRA)" <ji...@apache.org> on 2007/10/02 08:47:50 UTC

[jira] Created: (AXIS2-3238) Encoding of text messages using SOAP over JMS

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: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


Re: [jira] Created: (AXIS2-3238) Encoding of text messages using SOAP over JMS

Posted by "Asankha C. Perera" <as...@wso2.com>.
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: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


[jira] Assigned: (AXIS2-3238) Encoding of text messages using SOAP over JMS

Posted by "Deepal Jayasinghe (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AXIS2-3238?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Deepal Jayasinghe reassigned AXIS2-3238:
----------------------------------------

    Assignee: Asankha C. Perera

> 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
>            Assignee: Asankha C. Perera
>
> 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: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


[jira] Resolved: (AXIS2-3238) Encoding of text messages using SOAP over JMS

Posted by "Asankha C. Perera (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AXIS2-3238?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Asankha C. Perera resolved AXIS2-3238.
--------------------------------------

       Resolution: Fixed
    Fix Version/s: 1.5

The problematic area reported has been fixed sometime back

Please check with WS-Commons transport revision 724432

> 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
>            Assignee: Asankha C. Perera
>             Fix For: 1.5
>
>
> 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: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org