axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sc...@apache.org
Subject svn commit: r556720 - in /webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message: Message.java impl/MessageImpl.java util/MessageUtils.java
Date Mon, 16 Jul 2007 20:24:05 GMT
Author: scheu
Date: Mon Jul 16 13:24:03 2007
New Revision: 556720

URL: http://svn.apache.org/viewvc?view=rev&rev=556720
Log:
Contributor:Rich Scheuerle
Simplified the JAX-WS Message code.
Instead of using a SOAP MimeHeaders to hold the transport header values, 
the TRANSPORT_HEADERS map is used directly.

Modified:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/Message.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/MessageImpl.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/MessageUtils.java

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/Message.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/Message.java?view=diff&rev=556720&r1=556719&r2=556720
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/Message.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/Message.java
Mon Jul 16 13:24:03 2007
@@ -22,11 +22,11 @@
 import org.apache.axis2.jaxws.message.factory.BlockFactory;
 
 import javax.activation.DataHandler;
-import javax.xml.soap.MimeHeaders;
 import javax.xml.soap.SOAPMessage;
 import javax.xml.ws.WebServiceException;
+
 import java.util.List;
-import java.util.Set;
+import java.util.Map;
 
 /**
  * Message
@@ -119,15 +119,16 @@
     public void setMTOMEnabled(boolean b);
     
 
-    /** @return get the MimeHeaders */
-    public MimeHeaders getMimeHeaders();
+    /** 
+     * @return get the transport headers map.
+     */
+    public Map getMimeHeaders();
 
     /**
-     * Set the MimeHeaders
-     *
-     * @param mhs MimeHeaders
+     * Set the transport headers
+     * @param map Map
      */
-    public void setMimeHeaders(MimeHeaders mhs);
+    public void setMimeHeaders(Map map);
 
     /**
      * Indicate that this message is passed the pivot point. For example, this is set in
the JAX-WS

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/MessageImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/MessageImpl.java?view=diff&rev=556720&r1=556719&r2=556720
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/MessageImpl.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/MessageImpl.java
Mon Jul 16 13:24:03 2007
@@ -58,7 +58,10 @@
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
+import java.util.HashMap;
+import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 
 /**
  * MessageImpl
@@ -75,7 +78,10 @@
     XMLPart xmlPart = null; // the representation of the xmlpart
     
     boolean mtomEnabled;
-    private MimeHeaders mimeHeaders = new MimeHeaders(); 
+    
+    // The transport headers are stored in a Map, which is the 
+    // same data representation used by the Axis2 MessageContext (TRANSPORT_HEADERS).
+    private Map transportHeaders = null; 
     
     // The Message is connected to a MessageContext.
     // Prior to that connection, attachments are stored locally
@@ -192,8 +198,26 @@
             // Create soapMessage object from Message Factory using the input
             // stream created from OM.
             
-            // Get the MimeHeaders
-            MimeHeaders defaultHeaders = this.getMimeHeaders();
+            // Get the MimeHeaders from the transportHeaders map
+            MimeHeaders defaultHeaders = new MimeHeaders();
+            if (transportHeaders != null) {
+                Iterator it = transportHeaders.entrySet().iterator();
+                while (it.hasNext()) {
+                    Map.Entry entry = (Map.Entry) it.next();
+                    String key = (String) entry.getKey();
+                    if (entry.getValue() instanceof String) {
+                        // Normally there is one value per key
+                        defaultHeaders.addHeader(key, (String) entry.getValue());
+                    } else {
+                        // There may be multiple values for each key.  This code
+                        // assumes the value is an array of String.
+                        String values[] = (String[]) entry.getValue();
+                        for (int i=0; i<values.length; i++) {
+                            defaultHeaders.addHeader(key, values[i]);
+                        }
+                    }
+                }
+            }
             
             // Toggle based on SOAP 1.1 or SOAP 1.2
             String contentType = null;
@@ -512,18 +536,22 @@
     /* (non-Javadoc)
      * @see org.apache.axis2.jaxws.message.Attachment#getMimeHeaders()
      */
-    public MimeHeaders getMimeHeaders() {
-        return mimeHeaders;
-    }
+    public Map getMimeHeaders() {
+        // Lazily create transport headers.
+        if (transportHeaders == null) {
+            transportHeaders = new HashMap();
+        }
+        return transportHeaders;
+     }
     
     /* (non-Javadoc)
-     * @see org.apache.axis2.jaxws.message.Attachment#setMimeHeaders(javax.xml.soap.MimeHeaders)
+     * @see org.apache.axis2.jaxws.message.Attachment#setMimeHeaders(java.util.Map)
      */
-    public void setMimeHeaders(MimeHeaders mhs) {
-        mimeHeaders = mhs;
-        if (mimeHeaders == null) {
-            mimeHeaders = new MimeHeaders();
-        }
+    public void setMimeHeaders(Map map) {
+        transportHeaders = map;
+        if (transportHeaders == null) {
+            transportHeaders = new HashMap();
+          }
     }
     
     public Block getBodyBlock(Object context, BlockFactory blockFactory) 

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/MessageUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/MessageUtils.java?view=diff&rev=556720&r1=556719&r2=556720
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/MessageUtils.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/MessageUtils.java
Mon Jul 16 13:24:03 2007
@@ -158,16 +158,11 @@
             }
 
             // Add all the MimeHeaders from the Axis2 MessageContext
-            MimeHeaders mhs = message.getMimeHeaders();
             Map headerMap = (Map)msgContext.getProperty(MessageContext.TRANSPORT_HEADERS);
             if (headerMap != null) {
-                Iterator it = headerMap.keySet().iterator();
-                while (it.hasNext()) {
-                    String key = (String)it.next();
-                    String value = (String)headerMap.get(key);
-                    mhs.addHeader(key, value);
-                }
+                message.setMimeHeaders(headerMap);
             }
+            
             // TODO: This is a WORKAROUND for missing SOAPFault data.  If we do a toString
on the
             // SOAPEnvelope, then all the data will be available to the provider.  Otherwise,
it
             // will be missing the <Reason> element corresponding to the <faultstring>
element.  
@@ -197,12 +192,7 @@
         msgContext.setEnvelope(envelope);
 
         // Put the Headers onto the MessageContext
-        // TODO: Merge with latest TransportHeaders impl.
-        Map headerMap = new HashMap();
-        for (Iterator it = message.getMimeHeaders().getAllHeaders(); it.hasNext();) {
-            MimeHeader mh = (MimeHeader)it.next();
-            headerMap.put(mh.getName(), mh.getValue());
-        }
+        Map headerMap = message.getMimeHeaders();
         msgContext.setProperty(MessageContext.TRANSPORT_HEADERS, headerMap);
 
         if (message.getProtocol() == Protocol.rest) {



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message