[jbossws-commits] JBossWS SVN: r8542 - in stack/native/branches/jbossws-native-2.0.1.SP2_CP/src: main/java/org/jboss/ws/core/soap and 1 other directories.

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Wed Oct 22 11:00:04 EDT 2008


Author: alessio.soldano at jboss.com
Date: 2008-10-22 11:00:04 -0400 (Wed, 22 Oct 2008)
New Revision: 8542

Added:
   stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/binding/ClientHandler2.java
Modified:
   stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/core/jaxws/client/DispatchImpl.java
   stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/core/soap/SOAPMessageImpl.java
   stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/binding/SOAPBindingTestCase.java
Log:
[JBPAPP-1288] Porting  JBWS-1876: Wrong Content-Type in SOAP 1.2 messages


Modified: stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/core/jaxws/client/DispatchImpl.java
===================================================================
--- stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/core/jaxws/client/DispatchImpl.java	2008-10-22 11:05:46 UTC (rev 8541)
+++ stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/core/jaxws/client/DispatchImpl.java	2008-10-22 15:00:04 UTC (rev 8542)
@@ -45,12 +45,15 @@
 
 import org.jboss.logging.Logger;
 import org.jboss.util.NotImplementedException;
+import org.jboss.ws.core.CommonMessageContext;
 import org.jboss.ws.core.MessageAbstraction;
 import org.jboss.ws.core.ConfigProvider;
 import org.jboss.ws.core.client.HTTPRemotingConnection;
 import org.jboss.ws.core.client.RemotingConnection;
 import org.jboss.ws.core.client.SOAPRemotingConnection;
 import org.jboss.ws.core.jaxws.binding.BindingProviderImpl;
+import org.jboss.ws.core.jaxws.handler.SOAPMessageContextJAXWS;
+import org.jboss.ws.core.soap.MessageContextAssociation;
 import org.jboss.ws.metadata.umdm.EndpointMetaData;
 import org.jboss.ws.metadata.config.ConfigurationProvider;
 
@@ -180,6 +183,9 @@
 
    public void invokeOneWay(T msg)
    {
+      CommonMessageContext msgContext = new SOAPMessageContextJAXWS();
+      MessageContextAssociation.pushMessageContext(msgContext);
+      msgContext.setEndpointMetaData(epMetaData);
       try
       {
          MessageAbstraction reqMsg = getRequestMessage(msg);
@@ -190,6 +196,10 @@
       {
          handleInvokeException(ex);
       }
+      finally
+      {
+         MessageContextAssociation.popMessageContext();
+      }
    }
 
    // 4.17. Conformance (Failed Dispatch.invoke): When an operation is invoked using an invoke method, an

Modified: stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/core/soap/SOAPMessageImpl.java
===================================================================
--- stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/core/soap/SOAPMessageImpl.java	2008-10-22 11:05:46 UTC (rev 8541)
+++ stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/core/soap/SOAPMessageImpl.java	2008-10-22 15:00:04 UTC (rev 8542)
@@ -23,6 +23,7 @@
 
 // $Id$
 
+import org.jboss.ws.Constants;
 import org.jboss.ws.WSException;
 import org.jboss.ws.core.SOAPMessageAbstraction;
 import org.jboss.ws.core.CommonMessageContext;
@@ -208,6 +209,24 @@
 
       return new MimeMatchingAttachmentsIterator(headers, attachments);
    }
+   
+   private String getSOAPContentType() throws SOAPException
+   {
+      //Check binding type in the endpoint metadata
+      CommonMessageContext msgContext = MessageContextAssociation.peekMessageContext();
+      if (msgContext != null && Constants.SOAP12HTTP_BINDING.equalsIgnoreCase(msgContext.getEndpointMetaData().getBindingId()))
+      {
+         return SOAPConstants.SOAP_1_2_CONTENT_TYPE;
+      }
+      //Check the message envelope
+      SOAPEnvelope env = soapPart != null ? soapPart.getEnvelope() : null;
+      if (env != null && SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE.equals(env.getNamespaceURI()))
+      {
+         return SOAPConstants.SOAP_1_2_CONTENT_TYPE;
+      }
+      //Default to soap 1.1
+      return SOAPConstants.SOAP_1_1_CONTENT_TYPE;
+   }
 
    public void saveChanges() throws SOAPException
    {
@@ -221,7 +240,7 @@
                throw new IllegalStateException("XOP parameter not properly inlined");
 
             // default content-type
-            String contentType = MimeConstants.TYPE_SOAP11 + "; charset=" + getCharSetEncoding();
+            String contentType = getSOAPContentType() + "; charset=" + getCharSetEncoding();
 
             if (hasAttachments)
             {

Added: stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/binding/ClientHandler2.java
===================================================================
--- stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/binding/ClientHandler2.java	                        (rev 0)
+++ stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/binding/ClientHandler2.java	2008-10-22 15:00:04 UTC (rev 8542)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.binding;
+
+import javax.xml.soap.MimeHeaders;
+import javax.xml.soap.SOAPConstants;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+
+import org.jboss.logging.Logger;
+import org.jboss.ws.core.jaxws.handler.GenericSOAPHandler;
+
+/**
+ * A client side handler
+ *
+ * @author Alessio Soldano, alessio.soldano at jboss.com
+ * @since 31-Oct-2007
+ */
+public class ClientHandler2 extends GenericSOAPHandler
+{
+   private static Logger log = Logger.getLogger(ClientHandler2.class);
+
+   public boolean handleInbound(MessageContext msgContext)
+   {
+      log.info("handleInbound");
+
+      SOAPMessage soapMessage = ((SOAPMessageContext)msgContext).getMessage();
+
+      MimeHeaders mimeHeaders = soapMessage.getMimeHeaders();
+      String[] ct = mimeHeaders.getHeader("Content-Type");
+      if (ct != null)
+      {
+         for (int i = 0; i < ct.length; i++)
+         {
+            if (ct[i].startsWith(SOAPConstants.SOAP_1_2_CONTENT_TYPE))
+               return true;
+         }
+      }
+      return false;
+   }
+
+   protected boolean handleOutbound(MessageContext msgContext)
+   {
+      log.info("handleOutbound");
+
+      try
+      {
+         SOAPMessage soapMessage = ((SOAPMessageContext)msgContext).getMessage();
+         soapMessage.saveChanges();
+
+         MimeHeaders mimeHeaders = soapMessage.getMimeHeaders();
+         String[] ct = mimeHeaders.getHeader("Content-Type");
+         if (ct != null)
+         {
+            for (int i = 0; i < ct.length; i++)
+            {
+               if (ct[i].startsWith(SOAPConstants.SOAP_1_2_CONTENT_TYPE))
+                  return true;
+            }
+         }
+         return false;
+      }
+      catch (SOAPException ex)
+      {
+         throw new WebServiceException(ex);
+      }
+   }
+}


Property changes on: stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/binding/ClientHandler2.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/binding/SOAPBindingTestCase.java
===================================================================
--- stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/binding/SOAPBindingTestCase.java	2008-10-22 11:05:46 UTC (rev 8541)
+++ stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/binding/SOAPBindingTestCase.java	2008-10-22 15:00:04 UTC (rev 8542)
@@ -62,6 +62,7 @@
       List<Handler> handlerChain = new ArrayList<Handler>(); 
       handlerChain.addAll(provider.getBinding().getHandlerChain());
       handlerChain.add(new ClientHandler());
+      handlerChain.add(new ClientHandler2());
       provider.getBinding().setHandlerChain(handlerChain);
       
       String nsURI = port.namespace();




More information about the jbossws-commits mailing list