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 ji...@apache.org on 2004/02/27 15:47:32 UTC

[jira] Created: (AXIS-1242) Multipart messages using jms transport lack a contentType setting and fail to parse

Message:

  A new issue has been created in JIRA.

---------------------------------------------------------------------
View the issue:
  http://nagoya.apache.org/jira/secure/ViewIssue.jspa?key=AXIS-1242

Here is an overview of the issue:
---------------------------------------------------------------------
        Key: AXIS-1242
    Summary: Multipart messages using jms transport lack a contentType setting and fail to parse
       Type: Bug

     Status: Unassigned
   Priority: Major

    Project: Axis
 Components: 
             Basic Architecture
   Versions:
             1.2 Alpha

   Assignee: 
   Reporter: Tom Nelson

    Created: Fri, 27 Feb 2004 6:47 AM
    Updated: Fri, 27 Feb 2004 6:47 AM
Environment: tested on OSX with jboss-3.2.3 and j2sdk1.4.1

Description:
When using jms transport, the mime type of attachments is not passed from
the jms BytesMessage to the Message created in SimpleJMSWorker. The
following patch to JMSSender sets a contentType property in the send
properties of the outgoing message. When the BytesMessage is received
by the SimpleJMSWorker, it looks for the contentType property and if set,
creates a new Message with the contentType set. This change allows
messages with or without attachments to be parsed correctly.

Tom Nelson
RABA Technologies

Index: JMSSender.java
===================================================================
RCS file: /home/cvspublic/ws-axis/java/src/org/apache/axis/transport/jms/JMSSender.java,v
retrieving revision 1.7
diff -u -p -r1.7 JMSSender.java
--- JMSSender.java	25 Feb 2004 14:02:46 -0000	1.7
+++ JMSSender.java	27 Feb 2004 14:30:18 -0000
@@ -20,6 +20,7 @@ import org.apache.axis.AxisFault;
 import org.apache.axis.Message;
 import org.apache.axis.MessageContext;
 import org.apache.axis.handlers.BasicHandler;
+import org.apache.axis.attachments.Attachments;
 
 import javax.jms.Destination;
 import java.io.ByteArrayOutputStream;
@@ -69,6 +70,21 @@ public class JMSSender extends BasicHand
             msgContext.getRequestMessage().writeTo(out);
 
             HashMap props = createSendProperties(msgContext);
+
+            // If the request message contains attachments, set
+            // a contentType property to go in the outgoing message header
+            String ret = null;
+            Message message = msgContext.getRequestMessage();
+            Attachments mAttachments = message.getAttachmentsImpl();
+            if (mAttachments != null && 0 != mAttachments.getAttachmentCount()) 
+            {
+                String contentType = mAttachments.getContentType();
+                if(contentType != null && !contentType.trim().equals("")) 
+                {
+                    props.put("contentType", contentType);
+                }
+            }
+
             boolean waitForResponse = true;
             if(msgContext.containsProperty(JMSConstants.WAIT_FOR_RESPONSE))
                 waitForResponse =
Index: SimpleJMSWorker.java
===================================================================
RCS file: /home/cvspublic/ws-axis/java/src/org/apache/axis/transport/jms/SimpleJMSWorker.java,v
retrieving revision 1.6
diff -u -p -r1.6 SimpleJMSWorker.java
--- SimpleJMSWorker.java	25 Feb 2004 14:02:46 -0000	1.6
+++ SimpleJMSWorker.java	27 Feb 2004 14:30:18 -0000
@@ -80,7 +80,29 @@ public class SimpleJMSWorker implements 
 
         // create the msg and context and invoke the server
         AxisServer server = SimpleJMSListener.getAxisServer();
-        Message msg = new Message(in);
+
+        // if the incoming message has a contentType set,
+        // pass it to my new Message
+        String contentType = null;
+        try 
+        { 
+            contentType = message.getStringProperty("contentType");
+        } 
+        catch(Exception e) 
+        { 
+            e.printStackTrace();
+        }
+
+        Message msg = null;
+        if(contentType != null && !contentType.trim().equals("")) 
+        {
+            msg = new Message(in, true, contentType, null);
+        } 
+        else 
+        {
+            msg = new Message(in);
+        }
+
         MessageContext  msgContext = new MessageContext(server);
         msgContext.setRequestMessage( msg );
         try



---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.

If you think it was sent incorrectly contact one of the administrators:
   http://nagoya.apache.org/jira/secure/Administrators.jspa

If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira