Author: darran.lofthouse(a)jboss.com
Date: 2008-10-30 11:34:08 -0400 (Thu, 30 Oct 2008)
New Revision: 8600
Added:
stack/native/branches/jbossws-native-2.0.1.SP2_CP03_JBPAPP-1357/src/test/java/org/jboss/test/ws/jaxws/binding/ClientHandler2.java
Modified:
stack/native/branches/jbossws-native-2.0.1.SP2_CP03_JBPAPP-1357/src/main/java/org/jboss/ws/core/jaxws/client/DispatchImpl.java
stack/native/branches/jbossws-native-2.0.1.SP2_CP03_JBPAPP-1357/src/main/java/org/jboss/ws/core/soap/SOAPMessageImpl.java
stack/native/branches/jbossws-native-2.0.1.SP2_CP03_JBPAPP-1357/src/test/java/org/jboss/test/ws/jaxws/binding/SOAPBindingTestCase.java
Log:
[JBPAPP-1357] Wrong Content-Type in SOAP 1.2 messages.
Modified:
stack/native/branches/jbossws-native-2.0.1.SP2_CP03_JBPAPP-1357/src/main/java/org/jboss/ws/core/jaxws/client/DispatchImpl.java
===================================================================
---
stack/native/branches/jbossws-native-2.0.1.SP2_CP03_JBPAPP-1357/src/main/java/org/jboss/ws/core/jaxws/client/DispatchImpl.java 2008-10-30
15:13:34 UTC (rev 8599)
+++
stack/native/branches/jbossws-native-2.0.1.SP2_CP03_JBPAPP-1357/src/main/java/org/jboss/ws/core/jaxws/client/DispatchImpl.java 2008-10-30
15:34:08 UTC (rev 8600)
@@ -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_CP03_JBPAPP-1357/src/main/java/org/jboss/ws/core/soap/SOAPMessageImpl.java
===================================================================
---
stack/native/branches/jbossws-native-2.0.1.SP2_CP03_JBPAPP-1357/src/main/java/org/jboss/ws/core/soap/SOAPMessageImpl.java 2008-10-30
15:13:34 UTC (rev 8599)
+++
stack/native/branches/jbossws-native-2.0.1.SP2_CP03_JBPAPP-1357/src/main/java/org/jboss/ws/core/soap/SOAPMessageImpl.java 2008-10-30
15:34:08 UTC (rev 8600)
@@ -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;
@@ -207,6 +208,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
{
@@ -220,7 +239,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)
{
Copied:
stack/native/branches/jbossws-native-2.0.1.SP2_CP03_JBPAPP-1357/src/test/java/org/jboss/test/ws/jaxws/binding/ClientHandler2.java
(from rev 8542,
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_CP03_JBPAPP-1357/src/test/java/org/jboss/test/ws/jaxws/binding/ClientHandler2.java
(rev 0)
+++
stack/native/branches/jbossws-native-2.0.1.SP2_CP03_JBPAPP-1357/src/test/java/org/jboss/test/ws/jaxws/binding/ClientHandler2.java 2008-10-30
15:34:08 UTC (rev 8600)
@@ -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(a)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);
+ }
+ }
+}
Modified:
stack/native/branches/jbossws-native-2.0.1.SP2_CP03_JBPAPP-1357/src/test/java/org/jboss/test/ws/jaxws/binding/SOAPBindingTestCase.java
===================================================================
---
stack/native/branches/jbossws-native-2.0.1.SP2_CP03_JBPAPP-1357/src/test/java/org/jboss/test/ws/jaxws/binding/SOAPBindingTestCase.java 2008-10-30
15:13:34 UTC (rev 8599)
+++
stack/native/branches/jbossws-native-2.0.1.SP2_CP03_JBPAPP-1357/src/test/java/org/jboss/test/ws/jaxws/binding/SOAPBindingTestCase.java 2008-10-30
15:34:08 UTC (rev 8600)
@@ -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();