Author: thomas.diesler(a)jboss.com
Date: 2008-01-10 09:16:57 -0500 (Thu, 10 Jan 2008)
New Revision: 5456
Added:
stack/native/trunk/src/main/java/org/jboss/ws/core/client/HTTPProtocolConnection.java
stack/native/trunk/src/main/java/org/jboss/ws/core/client/HTTPRemotingConnection.java
stack/native/trunk/src/main/java/org/jboss/ws/core/client/RemoteConnection.java
stack/native/trunk/src/main/java/org/jboss/ws/core/client/RemoteConnectionFactory.java
stack/native/trunk/src/main/java/org/jboss/ws/core/client/SOAPProtocolConnectionHTTP.java
stack/native/trunk/src/main/java/org/jboss/ws/core/client/SOAPProtocolConnectionJMS.java
stack/native/trunk/src/main/java/org/jboss/ws/core/soap/SOAPMessageUnMarshallerHTTP.java
stack/native/trunk/src/main/resources/jbossws-core.jar/META-INF/services/org.jboss.ws.core.client.RemoteConnection.http
stack/native/trunk/src/main/resources/jbossws-core.jar/META-INF/services/org.jboss.ws.core.client.RemoteConnection.jms
stack/native/trunk/src/test/resources/jaxws/samples/jmstransport/jmsservice.wsdl
Removed:
stack/native/trunk/src/main/java/org/jboss/ws/core/client/HTTPRemotingConnection.java
stack/native/trunk/src/main/java/org/jboss/ws/core/client/RemotingConnection.java
stack/native/trunk/src/main/java/org/jboss/ws/core/client/RemotingConnectionImpl.java
stack/native/trunk/src/main/java/org/jboss/ws/core/client/SOAPRemotingConnection.java
Modified:
stack/native/trunk/
stack/native/trunk/src/main/java/org/jboss/ws/core/CommonClient.java
stack/native/trunk/src/main/java/org/jboss/ws/core/jaxws/client/DispatchImpl.java
stack/native/trunk/src/main/java/org/jboss/ws/core/soap/SOAPConnectionImpl.java
stack/native/trunk/src/main/java/org/jboss/ws/core/soap/SOAPMessageUnMarshaller.java
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/jmstransport/JMSTransportTestCase.java
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/jmstransport/Organization.java
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/jmstransport/OrganizationJMSEndpoint.java
Log:
[JBWS-1911] Implement JMS transport for JAXWS client
Property changes on: stack/native/trunk
___________________________________________________________________
Name: svn:ignore
- output-eclipse
output
thirdparty
output*
version.properties.md5
ant.properties
clipboard.txt
+ output-eclipse
output
thirdparty
output*
version.properties.md5
ant.properties
clipboard.txt
clipboard.*
Modified: stack/native/trunk/src/main/java/org/jboss/ws/core/CommonClient.java
===================================================================
--- stack/native/trunk/src/main/java/org/jboss/ws/core/CommonClient.java 2008-01-10
12:21:02 UTC (rev 5455)
+++ stack/native/trunk/src/main/java/org/jboss/ws/core/CommonClient.java 2008-01-10
14:16:57 UTC (rev 5456)
@@ -47,7 +47,9 @@
import org.jboss.ws.WSException;
import org.jboss.ws.core.DirectionHolder.Direction;
import org.jboss.ws.core.client.EndpointInfo;
-import org.jboss.ws.core.client.SOAPRemotingConnection;
+import org.jboss.ws.core.client.RemoteConnection;
+import org.jboss.ws.core.client.RemoteConnectionFactory;
+import org.jboss.ws.core.client.SOAPProtocolConnectionHTTP;
import org.jboss.ws.core.jaxrpc.ParameterWrapping;
import org.jboss.ws.core.soap.MessageContextAssociation;
import org.jboss.ws.core.soap.Style;
@@ -334,8 +336,8 @@
if (shouldMaintainSession())
addSessionInfo(reqMessage, callProps);
- SOAPRemotingConnection remotingConnection = new SOAPRemotingConnection();
- MessageAbstraction resMessage = remotingConnection.invoke(reqMessage, epInfo,
oneway);
+ RemoteConnection remoteConnection = new
RemoteConnectionFactory().getRemoteConnection(epInfo);
+ MessageAbstraction resMessage = remoteConnection.invoke(reqMessage, epInfo,
oneway);
if (shouldMaintainSession())
saveSessionInfo(callProps, getRequestContext());
Copied:
stack/native/trunk/src/main/java/org/jboss/ws/core/client/HTTPProtocolConnection.java
(from rev 5449,
stack/native/trunk/src/main/java/org/jboss/ws/core/client/HTTPRemotingConnection.java)
===================================================================
--- stack/native/trunk/src/main/java/org/jboss/ws/core/client/HTTPProtocolConnection.java
(rev 0)
+++
stack/native/trunk/src/main/java/org/jboss/ws/core/client/HTTPProtocolConnection.java 2008-01-10
14:16:57 UTC (rev 5456)
@@ -0,0 +1,45 @@
+/*
+ * 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.ws.core.client;
+
+// $Id$
+
+import org.jboss.remoting.marshal.Marshaller;
+import org.jboss.remoting.marshal.UnMarshaller;
+import org.jboss.ws.core.jaxws.binding.HTTPMessageMarshaller;
+import org.jboss.ws.core.jaxws.binding.HTTPMessageUnMarshaller;
+
+/**
+ * @since 02-Apr-2007
+ */
+public class HTTPProtocolConnection extends HTTPRemotingConnection
+{
+ public UnMarshaller getUnmarshaller()
+ {
+ return new HTTPMessageUnMarshaller();
+ }
+
+ public Marshaller getMarshaller()
+ {
+ return new HTTPMessageMarshaller();
+ }
+}
Deleted:
stack/native/trunk/src/main/java/org/jboss/ws/core/client/HTTPRemotingConnection.java
===================================================================
---
stack/native/trunk/src/main/java/org/jboss/ws/core/client/HTTPRemotingConnection.java 2008-01-10
12:21:02 UTC (rev 5455)
+++
stack/native/trunk/src/main/java/org/jboss/ws/core/client/HTTPRemotingConnection.java 2008-01-10
14:16:57 UTC (rev 5456)
@@ -1,45 +0,0 @@
-/*
- * 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.ws.core.client;
-
-// $Id$
-
-import org.jboss.remoting.marshal.Marshaller;
-import org.jboss.remoting.marshal.UnMarshaller;
-import org.jboss.ws.core.jaxws.binding.HTTPMessageMarshaller;
-import org.jboss.ws.core.jaxws.binding.HTTPMessageUnMarshaller;
-
-/**
- * @since 02-Apr-2007
- */
-public class HTTPRemotingConnection extends RemotingConnectionImpl
-{
- protected UnMarshaller getUnmarshaller()
- {
- return new HTTPMessageUnMarshaller();
- }
-
- protected Marshaller getMarshaller()
- {
- return new HTTPMessageMarshaller();
- }
-}
Added:
stack/native/trunk/src/main/java/org/jboss/ws/core/client/HTTPRemotingConnection.java
===================================================================
--- stack/native/trunk/src/main/java/org/jboss/ws/core/client/HTTPRemotingConnection.java
(rev 0)
+++
stack/native/trunk/src/main/java/org/jboss/ws/core/client/HTTPRemotingConnection.java 2008-01-10
14:16:57 UTC (rev 5456)
@@ -0,0 +1,407 @@
+/*
+ * 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.ws.core.client;
+
+// $Id$
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.net.MalformedURLException;
+import java.net.SocketTimeoutException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.xml.rpc.Stub;
+import javax.xml.soap.MimeHeader;
+import javax.xml.soap.MimeHeaders;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.addressing.EndpointReference;
+
+import org.jboss.logging.Logger;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.Version;
+import org.jboss.remoting.marshal.MarshalFactory;
+import org.jboss.remoting.marshal.Marshaller;
+import org.jboss.remoting.marshal.UnMarshaller;
+import org.jboss.ws.core.CommonMessageContext;
+import org.jboss.ws.core.MessageAbstraction;
+import org.jboss.ws.core.MessageTrace;
+import org.jboss.ws.core.StubExt;
+import org.jboss.ws.core.WSTimeoutException;
+import org.jboss.ws.core.soap.MessageContextAssociation;
+import org.jboss.ws.metadata.config.EndpointProperty;
+
+import org.jboss.ws.extensions.wsrm.transport.RMChannel;
+import org.jboss.ws.extensions.wsrm.transport.RMTransportHelper;
+import org.jboss.ws.extensions.wsrm.transport.RMMetadata;
+
+/**
+ * SOAPConnection implementation.
+ * <p/>
+ *
+ * Per default HTTP 1.1 chunked encoding is used.
+ * This may be ovverriden through {@link
org.jboss.ws.metadata.config.EndpointProperty#CHUNKED_ENCODING_SIZE}.
+ * A chunksize value of zero disables chunked encoding.
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @author <a href="mailto:jason@stacksmash.com">Jason T.
Greene</a>
+ *
+ * @since 02-Feb-2005
+ */
+public abstract class HTTPRemotingConnection implements RemoteConnection
+{
+ // provide logging
+ private static Logger log = Logger.getLogger(HTTPRemotingConnection.class);
+
+ private Map<String, Object> clientConfig = new HashMap<String, Object>();
+
+ private static Map<String, String> metadataMap = new HashMap<String,
String>();
+ static
+ {
+ metadataMap.put(Stub.USERNAME_PROPERTY, "http.basic.username");
+ metadataMap.put(Stub.PASSWORD_PROPERTY, "http.basic.password");
+ metadataMap.put(BindingProvider.USERNAME_PROPERTY,
"http.basic.username");
+ metadataMap.put(BindingProvider.PASSWORD_PROPERTY,
"http.basic.password");
+ }
+ private static Map<String, String> configMap = new HashMap<String,
String>();
+ static
+ {
+ configMap.put(StubExt.PROPERTY_KEY_STORE,
"org.jboss.remoting.keyStore");
+ configMap.put(StubExt.PROPERTY_KEY_STORE_PASSWORD,
"org.jboss.remoting.keyStorePassword");
+ configMap.put(StubExt.PROPERTY_KEY_STORE_TYPE,
"org.jboss.remoting.keyStoreType");
+ configMap.put(StubExt.PROPERTY_TRUST_STORE,
"org.jboss.remoting.trustStore");
+ configMap.put(StubExt.PROPERTY_TRUST_STORE_PASSWORD,
"org.jboss.remoting.trustStorePassword");
+ configMap.put(StubExt.PROPERTY_TRUST_STORE_TYPE,
"org.jboss.remoting.trustStoreType");
+ }
+
+ private boolean closed;
+
+ private static final RMChannel RM_CHANNEL = RMChannel.getInstance();
+
+ public HTTPRemotingConnection()
+ {
+ // HTTPClientInvoker conect sends gratuitous POST
+ //
http://jira.jboss.com/jira/browse/JBWS-711
+ clientConfig.put(Client.ENABLE_LEASE, false);
+ }
+
+ public boolean isClosed()
+ {
+ return closed;
+ }
+
+ public void setClosed(boolean closed)
+ {
+ this.closed = closed;
+ }
+
+ /**
+ * Sends the given message to the specified endpoint.
+ *
+ * A null reqMessage signifies a HTTP GET request.
+ */
+ public MessageAbstraction invoke(MessageAbstraction reqMessage, Object endpoint,
boolean oneway) throws IOException
+ {
+ if (endpoint == null)
+ throw new IllegalArgumentException("Given endpoint cannot be null");
+
+ if (closed)
+ throw new IOException("Connection is already closed");
+
+ Object timeout = null;
+ String targetAddress;
+ Map<String, Object> callProps = new HashMap<String, Object>();
+
+ if (endpoint instanceof EndpointInfo)
+ {
+ EndpointInfo epInfo = (EndpointInfo)endpoint;
+ targetAddress = epInfo.getTargetAddress();
+ callProps = epInfo.getProperties();
+
+ if (callProps.containsKey(StubExt.PROPERTY_CLIENT_TIMEOUT))
+ {
+ timeout = callProps.get(StubExt.PROPERTY_CLIENT_TIMEOUT);
+ targetAddress = addURLParameter(targetAddress, "timeout",
timeout.toString());
+ }
+
+ }
+ else if (endpoint instanceof EndpointReference)
+ {
+ EndpointReference epr = (EndpointReference)endpoint;
+ targetAddress = epr.getAddress().toString();
+ }
+ else
+ {
+ targetAddress = endpoint.toString();
+ }
+
+ // setup remoting client
+ Map<String, Object> metadata = createRemotingMetaData(reqMessage,
callProps);
+ Marshaller marshaller = getMarshaller();
+ UnMarshaller unmarshaller = getUnmarshaller();
+ InvokerLocator locator = null;
+ try
+ {
+ // Get the invoker from Remoting for a given endpoint address
+ log.debug("Get locator for: " + endpoint);
+
+ /**
+ * [JBWS-1704] The Use Of Remoting Causes An Additional 'datatype'
Parameter To Be Sent On All Requests
+ *
+ * An HTTPClientInvoker may disconnect from the server and recreated by the
remoting layer.
+ * In that case the new invoker does not inherit the marshaller/unmarshaller
from the disconnected invoker.
+ * We therefore explicitly specify the invoker locator datatype and register the
SOAP marshaller/unmarshaller
+ * with the MarshalFactory.
+ *
+ * This applies to remoting-1.4.5 and less
+ */
+ String version = getRemotingVersion();
+ if (version.startsWith("1.4"))
+ {
+ targetAddress = addURLParameter(targetAddress, InvokerLocator.DATATYPE,
"JBossWSMessage");
+ MarshalFactory.addMarshaller("JBossWSMessage", marshaller,
unmarshaller);
+ }
+
+ locator = new InvokerLocator(targetAddress);
+ }
+ catch (MalformedURLException e)
+ {
+ throw new IllegalArgumentException("Malformed endpoint address", e);
+ }
+
+ try
+ {
+ if (RMTransportHelper.isRMMessage(callProps))
+ {
+ RMMetadata rmMetadata = new RMMetadata(getRemotingVersion(), targetAddress,
marshaller, unmarshaller, callProps, metadata, clientConfig);
+ return RM_CHANNEL.send(reqMessage, rmMetadata);
+ }
+ else
+ {
+ Client client = new Client(locator, "jbossws", clientConfig);
+ client.connect();
+
+ client.setMarshaller(marshaller);
+
+ if (oneway == false)
+ client.setUnMarshaller(unmarshaller);
+
+ if (log.isDebugEnabled())
+ log.debug("Remoting metadata: " + metadata);
+
+ // debug the outgoing message
+ MessageTrace.traceMessage("Outgoing Request Message", reqMessage);
+
+ MessageAbstraction resMessage = null;
+
+ if (oneway == true)
+ {
+ client.invokeOneway(reqMessage, metadata, false);
+ }
+ else
+ {
+ resMessage = (MessageAbstraction)client.invoke(reqMessage, metadata);
+ }
+
+ // Disconnect the remoting client
+ client.disconnect();
+
+ callProps.clear();
+ callProps.putAll(metadata);
+
+ // trace the incomming response message
+ MessageTrace.traceMessage("Incoming Response Message",
resMessage);
+
+ return resMessage;
+ }
+ }
+ catch (Throwable th)
+ {
+ if (timeout != null && (th.getCause() instanceof
SocketTimeoutException))
+ {
+ throw new WSTimeoutException("Timeout after: " + timeout +
"ms", new Long(timeout.toString()));
+ }
+
+ IOException io = new IOException("Could not transmit message");
+ io.initCause(th);
+ throw io;
+ }
+ }
+
+ private String addURLParameter(String urlStr, String key, String value) throws
MalformedURLException
+ {
+ URL url = new URL(urlStr);
+ urlStr += (url.getQuery() == null ? "?" : "&") + key +
"=" + value;
+ return urlStr;
+ }
+
+ private String getRemotingVersion()
+ {
+ String version = null;
+ try
+ {
+ // Access the constant dynamically, otherwise it will be the compile time value
+ Field field = Version.class.getDeclaredField("VERSION");
+ version = (String)field.get(null);
+ }
+ catch (Exception ex)
+ {
+ throw new RuntimeException("Cannot obtain remoting version", ex);
+ }
+
+ if (version == null)
+ {
+ URL codeURL =
Version.class.getProtectionDomain().getCodeSource().getLocation();
+ throw new RuntimeException("Cannot obtain remoting version from: " +
codeURL);
+ }
+ return version;
+ }
+
+ private Map<String, Object> createRemotingMetaData(MessageAbstraction
reqMessage, Map callProps)
+ {
+ CommonMessageContext msgContext = MessageContextAssociation.peekMessageContext();
+
+ Map<String, Object> metadata = new HashMap<String, Object>();
+
+ // We need to unmarshall faults (HTTP 500)
+ // metadata.put(HTTPMetadataConstants.NO_THROW_ON_ERROR, "true"); //
since 2.0.0.GA
+ metadata.put("NoThrowOnError", "true");
+
+ if (reqMessage != null)
+ {
+ populateHeaders(reqMessage, metadata);
+
+ // Enable chunked encoding. This is the default size.
+ clientConfig.put("chunkedLength", "1024");
+
+ // May be overridden through endpoint config
+ if (msgContext != null)
+ {
+ Properties epmdProps = msgContext.getEndpointMetaData().getProperties();
+
+ // chunksize settings
+ String chunkSizeValue =
epmdProps.getProperty(EndpointProperty.CHUNKED_ENCODING_SIZE);
+ int chunkSize = chunkSizeValue != null ? Integer.valueOf(chunkSizeValue) :
-1;
+ if (chunkSize > 0)
+ {
+ clientConfig.put(EndpointProperty.CHUNKED_ENCODING_SIZE, chunkSizeValue);
+ }
+ else
+ {
+ clientConfig.remove("chunkedLength");
+ }
+ }
+ }
+ else
+ {
+ metadata.put("TYPE", "GET");
+ }
+
+ if (callProps != null)
+ {
+ Iterator it = callProps.entrySet().iterator();
+
+ // Get authentication type, default to BASIC authetication
+ String authType = (String)callProps.get(StubExt.PROPERTY_AUTH_TYPE);
+ if (authType == null)
+ authType = StubExt.PROPERTY_AUTH_TYPE_BASIC;
+
+ while (it.hasNext())
+ {
+ Map.Entry entry = (Map.Entry)it.next();
+ String key = (String)entry.getKey();
+ Object val = entry.getValue();
+
+ // pass properties to remoting meta data
+ if (metadataMap.containsKey(key))
+ {
+ String remotingKey = metadataMap.get(key);
+ if ("http.basic.username".equals(remotingKey) ||
"http.basic.password".equals(remotingKey))
+ {
+ if (authType.equals(StubExt.PROPERTY_AUTH_TYPE_BASIC))
+ {
+ metadata.put(remotingKey, val);
+ }
+ else
+ {
+ log.warn("Ignore '" + key + "' with auth
typy: " + authType);
+ }
+ }
+ else
+ {
+ metadata.put(remotingKey, val);
+ }
+ }
+
+ // pass properties to remoting client config
+ if (configMap.containsKey(key))
+ {
+ String remotingKey = configMap.get(key);
+ clientConfig.put(remotingKey, val);
+ }
+ }
+ }
+
+ return metadata;
+ }
+
+ protected void populateHeaders(MessageAbstraction reqMessage, Map<String,
Object> metadata)
+ {
+ MimeHeaders mimeHeaders = reqMessage.getMimeHeaders();
+
+ Properties props = new Properties();
+ metadata.put("HEADER", props);
+
+ Iterator i = mimeHeaders.getAllHeaders();
+ while (i.hasNext())
+ {
+ MimeHeader header = (MimeHeader)i.next();
+ String currentValue = props.getProperty(header.getName());
+
+ /*
+ * Coalesce multiple headers into one
+ *
+ * From HTTP/1.1 RFC 2616:
+ *
+ * Multiple message-header fields with the same field-name MAY be
+ * present in a message if and only if the entire field-value for that
+ * header field is defined as a comma-separated list [i.e., #(values)].
+ * It MUST be possible to combine the multiple header fields into one
+ * "field-name: field-value" pair, without changing the semantics of
+ * the message, by appending each subsequent field-value to the first,
+ * each separated by a comma.
+ */
+ if (currentValue != null)
+ {
+ props.put(header.getName(), currentValue + "," +
header.getValue());
+ }
+ else
+ {
+ props.put(header.getName(), header.getValue());
+ }
+ }
+ }
+}
Copied: stack/native/trunk/src/main/java/org/jboss/ws/core/client/RemoteConnection.java
(from rev 5449,
stack/native/trunk/src/main/java/org/jboss/ws/core/client/RemotingConnection.java)
===================================================================
--- stack/native/trunk/src/main/java/org/jboss/ws/core/client/RemoteConnection.java
(rev 0)
+++
stack/native/trunk/src/main/java/org/jboss/ws/core/client/RemoteConnection.java 2008-01-10
14:16:57 UTC (rev 5456)
@@ -0,0 +1,46 @@
+/*
+ * 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.ws.core.client;
+
+
+import java.io.IOException;
+
+import org.jboss.remoting.marshal.Marshaller;
+import org.jboss.remoting.marshal.UnMarshaller;
+import org.jboss.ws.core.MessageAbstraction;
+
+// $Id$
+
+/**
+ * A remote connection
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 02-Apr-2007
+ */
+public interface RemoteConnection
+{
+ Marshaller getMarshaller();
+
+ UnMarshaller getUnmarshaller();
+
+ MessageAbstraction invoke(MessageAbstraction reqMessage, Object endpoint, boolean
oneway) throws IOException;
+}
Added:
stack/native/trunk/src/main/java/org/jboss/ws/core/client/RemoteConnectionFactory.java
===================================================================
---
stack/native/trunk/src/main/java/org/jboss/ws/core/client/RemoteConnectionFactory.java
(rev 0)
+++
stack/native/trunk/src/main/java/org/jboss/ws/core/client/RemoteConnectionFactory.java 2008-01-10
14:16:57 UTC (rev 5456)
@@ -0,0 +1,57 @@
+/*
+ * 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.ws.core.client;
+
+import org.jboss.wsf.spi.util.ServiceLoader;
+
+// $Id$
+
+/**
+ * A factory for remote connections
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 10-Jan-2008
+ */
+public class RemoteConnectionFactory
+{
+ public RemoteConnection getRemoteConnection(EndpointInfo epInfo)
+ {
+ String targetAddress = epInfo.getTargetAddress();
+ if (targetAddress == null)
+ throw new IllegalArgumentException("Cannot obtain target address from:
" + epInfo);
+
+ String key = null;
+ if (targetAddress.startsWith("http"))
+ key = RemoteConnection.class.getName() + ".http";
+ else if (targetAddress.startsWith("jms"))
+ key = RemoteConnection.class.getName() + ".jms";
+
+ if (key == null)
+ throw new IllegalArgumentException("Cannot obtain remote connetion for:
" + targetAddress);
+
+ RemoteConnection con = (RemoteConnection)ServiceLoader.loadService(key, null);
+ if (con == null)
+ throw new IllegalArgumentException("Cannot obtain remote connetion for:
" + key);
+
+ return con;
+ }
+}
Property changes on:
stack/native/trunk/src/main/java/org/jboss/ws/core/client/RemoteConnectionFactory.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Deleted:
stack/native/trunk/src/main/java/org/jboss/ws/core/client/RemotingConnection.java
===================================================================
---
stack/native/trunk/src/main/java/org/jboss/ws/core/client/RemotingConnection.java 2008-01-10
12:21:02 UTC (rev 5455)
+++
stack/native/trunk/src/main/java/org/jboss/ws/core/client/RemotingConnection.java 2008-01-10
14:16:57 UTC (rev 5456)
@@ -1,40 +0,0 @@
-/*
- * 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.ws.core.client;
-
-
-import java.io.IOException;
-
-import org.jboss.ws.core.MessageAbstraction;
-
-// $Id$
-
-/**
- * A remoting connection
- *
- * @author Thomas.Diesler(a)jboss.org
- * @since 02-Apr-2007
- */
-public interface RemotingConnection
-{
- MessageAbstraction invoke(MessageAbstraction reqMessage, Object endpoint, boolean
oneway) throws IOException;
-}
Deleted:
stack/native/trunk/src/main/java/org/jboss/ws/core/client/RemotingConnectionImpl.java
===================================================================
---
stack/native/trunk/src/main/java/org/jboss/ws/core/client/RemotingConnectionImpl.java 2008-01-10
12:21:02 UTC (rev 5455)
+++
stack/native/trunk/src/main/java/org/jboss/ws/core/client/RemotingConnectionImpl.java 2008-01-10
14:16:57 UTC (rev 5456)
@@ -1,411 +0,0 @@
-/*
- * 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.ws.core.client;
-
-// $Id$
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.net.MalformedURLException;
-import java.net.SocketTimeoutException;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Properties;
-
-import javax.xml.rpc.Stub;
-import javax.xml.soap.MimeHeader;
-import javax.xml.soap.MimeHeaders;
-import javax.xml.ws.BindingProvider;
-import javax.xml.ws.addressing.EndpointReference;
-
-import org.jboss.logging.Logger;
-import org.jboss.remoting.Client;
-import org.jboss.remoting.InvokerLocator;
-import org.jboss.remoting.Version;
-import org.jboss.remoting.marshal.MarshalFactory;
-import org.jboss.remoting.marshal.Marshaller;
-import org.jboss.remoting.marshal.UnMarshaller;
-import org.jboss.ws.core.CommonMessageContext;
-import org.jboss.ws.core.MessageAbstraction;
-import org.jboss.ws.core.MessageTrace;
-import org.jboss.ws.core.StubExt;
-import org.jboss.ws.core.WSTimeoutException;
-import org.jboss.ws.core.soap.MessageContextAssociation;
-import org.jboss.ws.metadata.config.EndpointProperty;
-
-import org.jboss.ws.extensions.wsrm.transport.RMChannel;
-import org.jboss.ws.extensions.wsrm.transport.RMTransportHelper;
-import org.jboss.ws.extensions.wsrm.transport.RMMetadata;
-
-/**
- * SOAPConnection implementation.
- * <p/>
- *
- * Per default HTTP 1.1 chunked encoding is used.
- * This may be ovverriden through {@link
org.jboss.ws.metadata.config.EndpointProperty#CHUNKED_ENCODING_SIZE}.
- * A chunksize value of zero disables chunked encoding.
- *
- * @author Thomas.Diesler(a)jboss.org
- * @author <a href="mailto:jason@stacksmash.com">Jason T.
Greene</a>
- *
- * @since 02-Feb-2005
- */
-public abstract class RemotingConnectionImpl implements RemotingConnection
-{
- // provide logging
- private static Logger log = Logger.getLogger(RemotingConnectionImpl.class);
-
- private Map<String, Object> clientConfig = new HashMap<String, Object>();
-
- private static Map<String, String> metadataMap = new HashMap<String,
String>();
- static
- {
- metadataMap.put(Stub.USERNAME_PROPERTY, "http.basic.username");
- metadataMap.put(Stub.PASSWORD_PROPERTY, "http.basic.password");
- metadataMap.put(BindingProvider.USERNAME_PROPERTY,
"http.basic.username");
- metadataMap.put(BindingProvider.PASSWORD_PROPERTY,
"http.basic.password");
- }
- private static Map<String, String> configMap = new HashMap<String,
String>();
- static
- {
- configMap.put(StubExt.PROPERTY_KEY_STORE,
"org.jboss.remoting.keyStore");
- configMap.put(StubExt.PROPERTY_KEY_STORE_PASSWORD,
"org.jboss.remoting.keyStorePassword");
- configMap.put(StubExt.PROPERTY_KEY_STORE_TYPE,
"org.jboss.remoting.keyStoreType");
- configMap.put(StubExt.PROPERTY_TRUST_STORE,
"org.jboss.remoting.trustStore");
- configMap.put(StubExt.PROPERTY_TRUST_STORE_PASSWORD,
"org.jboss.remoting.trustStorePassword");
- configMap.put(StubExt.PROPERTY_TRUST_STORE_TYPE,
"org.jboss.remoting.trustStoreType");
- }
-
- private boolean closed;
-
- private static final RMChannel RM_CHANNEL = RMChannel.getInstance();
-
- public RemotingConnectionImpl()
- {
- // HTTPClientInvoker conect sends gratuitous POST
- //
http://jira.jboss.com/jira/browse/JBWS-711
- clientConfig.put(Client.ENABLE_LEASE, false);
- }
-
- public boolean isClosed()
- {
- return closed;
- }
-
- public void setClosed(boolean closed)
- {
- this.closed = closed;
- }
-
- /**
- * Sends the given message to the specified endpoint.
- *
- * A null reqMessage signifies a HTTP GET request.
- */
- public MessageAbstraction invoke(MessageAbstraction reqMessage, Object endpoint,
boolean oneway) throws IOException
- {
- if (endpoint == null)
- throw new IllegalArgumentException("Given endpoint cannot be null");
-
- if (closed)
- throw new IOException("Connection is already closed");
-
- Object timeout = null;
- String targetAddress;
- Map<String, Object> callProps = new HashMap<String, Object>();
-
- if (endpoint instanceof EndpointInfo)
- {
- EndpointInfo epInfo = (EndpointInfo)endpoint;
- targetAddress = epInfo.getTargetAddress();
- callProps = epInfo.getProperties();
-
- if (callProps.containsKey(StubExt.PROPERTY_CLIENT_TIMEOUT))
- {
- timeout = callProps.get(StubExt.PROPERTY_CLIENT_TIMEOUT);
- targetAddress = addURLParameter(targetAddress, "timeout",
timeout.toString());
- }
-
- }
- else if (endpoint instanceof EndpointReference)
- {
- EndpointReference epr = (EndpointReference)endpoint;
- targetAddress = epr.getAddress().toString();
- }
- else
- {
- targetAddress = endpoint.toString();
- }
-
- // setup remoting client
- Map<String, Object> metadata = createRemotingMetaData(reqMessage,
callProps);
- Marshaller marshaller = getMarshaller();
- UnMarshaller unmarshaller = getUnmarshaller();
- InvokerLocator locator = null;
- try
- {
- // Get the invoker from Remoting for a given endpoint address
- log.debug("Get locator for: " + endpoint);
-
- /**
- * [JBWS-1704] The Use Of Remoting Causes An Additional 'datatype'
Parameter To Be Sent On All Requests
- *
- * An HTTPClientInvoker may disconnect from the server and recreated by the
remoting layer.
- * In that case the new invoker does not inherit the marshaller/unmarshaller
from the disconnected invoker.
- * We therefore explicitly specify the invoker locator datatype and register the
SOAP marshaller/unmarshaller
- * with the MarshalFactory.
- *
- * This applies to remoting-1.4.5 and less
- */
- String version = getRemotingVersion();
- if (version.startsWith("1.4"))
- {
- targetAddress = addURLParameter(targetAddress, InvokerLocator.DATATYPE,
"JBossWSMessage");
- MarshalFactory.addMarshaller("JBossWSMessage", marshaller,
unmarshaller);
- }
-
- locator = new InvokerLocator(targetAddress);
- }
- catch (MalformedURLException e)
- {
- throw new IllegalArgumentException("Malformed endpoint address", e);
- }
-
- try
- {
- if (RMTransportHelper.isRMMessage(callProps))
- {
- RMMetadata rmMetadata = new RMMetadata(getRemotingVersion(), targetAddress,
marshaller, unmarshaller, callProps, metadata, clientConfig);
- return RM_CHANNEL.send(reqMessage, rmMetadata);
- }
- else
- {
- Client client = new Client(locator, "jbossws", clientConfig);
- client.connect();
-
- client.setMarshaller(marshaller);
-
- if (oneway == false)
- client.setUnMarshaller(unmarshaller);
-
- if (log.isDebugEnabled())
- log.debug("Remoting metadata: " + metadata);
-
- // debug the outgoing message
- MessageTrace.traceMessage("Outgoing Request Message", reqMessage);
-
- MessageAbstraction resMessage = null;
-
- if (oneway == true)
- {
- client.invokeOneway(reqMessage, metadata, false);
- }
- else
- {
- resMessage = (MessageAbstraction)client.invoke(reqMessage, metadata);
- }
-
- // Disconnect the remoting client
- client.disconnect();
-
- callProps.clear();
- callProps.putAll(metadata);
-
- // trace the incomming response message
- MessageTrace.traceMessage("Incoming Response Message",
resMessage);
-
- return resMessage;
- }
- }
- catch (Throwable th)
- {
- if (timeout != null && (th.getCause() instanceof
SocketTimeoutException))
- {
- throw new WSTimeoutException("Timeout after: " + timeout +
"ms", new Long(timeout.toString()));
- }
-
- IOException io = new IOException("Could not transmit message");
- io.initCause(th);
- throw io;
- }
- }
-
- private String addURLParameter(String urlStr, String key, String value) throws
MalformedURLException
- {
- URL url = new URL(urlStr);
- urlStr += (url.getQuery() == null ? "?" : "&") + key +
"=" + value;
- return urlStr;
- }
-
- private String getRemotingVersion()
- {
- String version = null;
- try
- {
- // Access the constant dynamically, otherwise it will be the compile time value
- Field field = Version.class.getDeclaredField("VERSION");
- version = (String)field.get(null);
- }
- catch (Exception ex)
- {
- throw new RuntimeException("Cannot obtain remoting version", ex);
- }
-
- if (version == null)
- {
- URL codeURL =
Version.class.getProtectionDomain().getCodeSource().getLocation();
- throw new RuntimeException("Cannot obtain remoting version from: " +
codeURL);
- }
- return version;
- }
-
- protected abstract UnMarshaller getUnmarshaller();
-
- protected abstract Marshaller getMarshaller();
-
- private Map<String, Object> createRemotingMetaData(MessageAbstraction
reqMessage, Map callProps)
- {
- CommonMessageContext msgContext = MessageContextAssociation.peekMessageContext();
-
- Map<String, Object> metadata = new HashMap<String, Object>();
-
- // We need to unmarshall faults (HTTP 500)
- // metadata.put(HTTPMetadataConstants.NO_THROW_ON_ERROR, "true"); //
since 2.0.0.GA
- metadata.put("NoThrowOnError", "true");
-
- if (reqMessage != null)
- {
- populateHeaders(reqMessage, metadata);
-
- // Enable chunked encoding. This is the default size.
- clientConfig.put("chunkedLength", "1024");
-
- // May be overridden through endpoint config
- if (msgContext != null)
- {
- Properties epmdProps = msgContext.getEndpointMetaData().getProperties();
-
- // chunksize settings
- String chunkSizeValue =
epmdProps.getProperty(EndpointProperty.CHUNKED_ENCODING_SIZE);
- int chunkSize = chunkSizeValue != null ? Integer.valueOf(chunkSizeValue) :
-1;
- if (chunkSize > 0)
- {
- clientConfig.put(EndpointProperty.CHUNKED_ENCODING_SIZE, chunkSizeValue);
- }
- else
- {
- clientConfig.remove("chunkedLength");
- }
- }
- }
- else
- {
- metadata.put("TYPE", "GET");
- }
-
- if (callProps != null)
- {
- Iterator it = callProps.entrySet().iterator();
-
- // Get authentication type, default to BASIC authetication
- String authType = (String)callProps.get(StubExt.PROPERTY_AUTH_TYPE);
- if (authType == null)
- authType = StubExt.PROPERTY_AUTH_TYPE_BASIC;
-
- while (it.hasNext())
- {
- Map.Entry entry = (Map.Entry)it.next();
- String key = (String)entry.getKey();
- Object val = entry.getValue();
-
- // pass properties to remoting meta data
- if (metadataMap.containsKey(key))
- {
- String remotingKey = metadataMap.get(key);
- if ("http.basic.username".equals(remotingKey) ||
"http.basic.password".equals(remotingKey))
- {
- if (authType.equals(StubExt.PROPERTY_AUTH_TYPE_BASIC))
- {
- metadata.put(remotingKey, val);
- }
- else
- {
- log.warn("Ignore '" + key + "' with auth
typy: " + authType);
- }
- }
- else
- {
- metadata.put(remotingKey, val);
- }
- }
-
- // pass properties to remoting client config
- if (configMap.containsKey(key))
- {
- String remotingKey = configMap.get(key);
- clientConfig.put(remotingKey, val);
- }
- }
- }
-
- return metadata;
- }
-
- protected void populateHeaders(MessageAbstraction reqMessage, Map<String,
Object> metadata)
- {
- MimeHeaders mimeHeaders = reqMessage.getMimeHeaders();
-
- Properties props = new Properties();
- metadata.put("HEADER", props);
-
- Iterator i = mimeHeaders.getAllHeaders();
- while (i.hasNext())
- {
- MimeHeader header = (MimeHeader)i.next();
- String currentValue = props.getProperty(header.getName());
-
- /*
- * Coalesce multiple headers into one
- *
- * From HTTP/1.1 RFC 2616:
- *
- * Multiple message-header fields with the same field-name MAY be
- * present in a message if and only if the entire field-value for that
- * header field is defined as a comma-separated list [i.e., #(values)].
- * It MUST be possible to combine the multiple header fields into one
- * "field-name: field-value" pair, without changing the semantics of
- * the message, by appending each subsequent field-value to the first,
- * each separated by a comma.
- */
- if (currentValue != null)
- {
- props.put(header.getName(), currentValue + "," +
header.getValue());
- }
- else
- {
- props.put(header.getName(), header.getValue());
- }
- }
- }
-}
Added:
stack/native/trunk/src/main/java/org/jboss/ws/core/client/SOAPProtocolConnectionHTTP.java
===================================================================
---
stack/native/trunk/src/main/java/org/jboss/ws/core/client/SOAPProtocolConnectionHTTP.java
(rev 0)
+++
stack/native/trunk/src/main/java/org/jboss/ws/core/client/SOAPProtocolConnectionHTTP.java 2008-01-10
14:16:57 UTC (rev 5456)
@@ -0,0 +1,120 @@
+/*
+ * 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.ws.core.client;
+
+// $Id$
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.xml.soap.MimeHeader;
+import javax.xml.soap.MimeHeaders;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPMessage;
+
+import org.jboss.remoting.marshal.Marshaller;
+import org.jboss.remoting.marshal.UnMarshaller;
+import org.jboss.ws.WSException;
+import org.jboss.ws.core.MessageAbstraction;
+import org.jboss.ws.core.soap.SOAPMessageMarshaller;
+import org.jboss.ws.core.soap.SOAPMessageUnMarshallerHTTP;
+import org.jboss.ws.extensions.xop.XOPContext;
+
+/**
+ * SOAPConnection implementation
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @author <a href="mailto:jason@stacksmash.com">Jason T.
Greene</a>
+ *
+ * @since 02-Apr-2007
+ */
+public class SOAPProtocolConnectionHTTP extends HTTPRemotingConnection
+{
+ public UnMarshaller getUnmarshaller()
+ {
+ return new SOAPMessageUnMarshallerHTTP();
+ }
+
+ public Marshaller getMarshaller()
+ {
+ return new SOAPMessageMarshaller();
+ }
+
+ public MessageAbstraction invoke(MessageAbstraction reqMessage, Object endpoint,
boolean oneway) throws IOException
+ {
+ try
+ {
+ // enforce xop transitions
+ // TODO: there should be a clear transition to an immutable object model
+ XOPContext.eagerlyCreateAttachments();
+
+ // save object model changes
+ SOAPMessage soapMessage = (SOAPMessage)reqMessage;
+ if (reqMessage != null && soapMessage.saveRequired())
+ soapMessage.saveChanges();
+
+ return super.invoke(reqMessage, endpoint, oneway);
+ }
+ catch (SOAPException ex)
+ {
+ IOException io = new IOException();
+ io.initCause(ex);
+ throw io;
+ }
+ }
+
+ protected void populateHeaders(MessageAbstraction reqMessage, Map<String,
Object> metadata)
+ {
+ super.populateHeaders(reqMessage, metadata);
+
+ Properties props = (Properties)metadata.get("HEADER");
+
+ // R2744 A HTTP request MESSAGE MUST contain a SOAPAction HTTP header field
+ // with a quoted value equal to the value of the soapAction attribute of
+ // soapbind:operation, if present in the corresponding WSDL description.
+
+ // R2745 A HTTP request MESSAGE MUST contain a SOAPAction HTTP header field
+ // with a quoted empty string value, if in the corresponding WSDL description,
+ // the soapAction attribute of soapbind:operation is either not present, or
+ // present with an empty string as its value.
+
+ MimeHeaders mimeHeaders = reqMessage.getMimeHeaders();
+ String[] action = mimeHeaders.getHeader("SOAPAction");
+ if (action != null && action.length > 0)
+ {
+ String soapAction = action[0];
+
+ // R1109 The value of the SOAPAction HTTP header field in a HTTP request MESSAGE
MUST be a quoted string.
+ if (soapAction.startsWith("\"") == false ||
soapAction.endsWith("\"") == false)
+ soapAction = "\"" + soapAction + "\"";
+
+ props.put("SOAPAction", soapAction);
+ }
+ else
+ {
+ props.put("SOAPAction", "\"\"");
+ }
+
+ }
+}
Property changes on:
stack/native/trunk/src/main/java/org/jboss/ws/core/client/SOAPProtocolConnectionHTTP.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
stack/native/trunk/src/main/java/org/jboss/ws/core/client/SOAPProtocolConnectionJMS.java
===================================================================
---
stack/native/trunk/src/main/java/org/jboss/ws/core/client/SOAPProtocolConnectionJMS.java
(rev 0)
+++
stack/native/trunk/src/main/java/org/jboss/ws/core/client/SOAPProtocolConnectionJMS.java 2008-01-10
14:16:57 UTC (rev 5456)
@@ -0,0 +1,205 @@
+/*
+ * 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.ws.core.client;
+
+// $Id$
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.net.URI;
+import java.util.StringTokenizer;
+
+import javax.jms.BytesMessage;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.Queue;
+import javax.jms.QueueConnection;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.QueueReceiver;
+import javax.jms.QueueSender;
+import javax.jms.QueueSession;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.naming.InitialContext;
+import javax.xml.ws.addressing.EndpointReference;
+
+import org.jboss.remoting.marshal.Marshaller;
+import org.jboss.remoting.marshal.UnMarshaller;
+import org.jboss.ws.core.MessageAbstraction;
+import org.jboss.ws.core.soap.SOAPMessageMarshaller;
+import org.jboss.ws.core.soap.SOAPMessageUnMarshaller;
+
+/**
+ * A SOAPConnection over JMS
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 10-Jan-2008
+ */
+public class SOAPProtocolConnectionJMS implements RemoteConnection
+{
+ private boolean waitForResponse;
+
+ public UnMarshaller getUnmarshaller()
+ {
+ return new SOAPMessageUnMarshaller();
+ }
+
+ public Marshaller getMarshaller()
+ {
+ return new SOAPMessageMarshaller();
+ }
+
+ public MessageAbstraction invoke(MessageAbstraction reqMessage, Object endpoint,
boolean oneway) throws IOException
+ {
+ if (endpoint == null)
+ throw new IllegalArgumentException("Given endpoint cannot be null");
+
+ // Get target address
+ String targetAddress;
+ if (endpoint instanceof EndpointInfo)
+ {
+ EndpointInfo epInfo = (EndpointInfo)endpoint;
+ targetAddress = epInfo.getTargetAddress();
+ }
+ else if (endpoint instanceof EndpointReference)
+ {
+ EndpointReference epr = (EndpointReference)endpoint;
+ targetAddress = epr.getAddress().toString();
+ }
+ else
+ {
+ targetAddress = endpoint.toString();
+ }
+
+ try
+ {
+ URI jmsURI = new URI(targetAddress);
+ String uriHost = jmsURI.getHost();
+ String uriPath = jmsURI.getPath();
+
+ String reqQueueName = getURLProperty(jmsURI, "destinationName");
+ if (reqQueueName == null)
+ {
+ reqQueueName = uriHost;
+ if (uriPath != null && uriPath.length() > 0)
+ reqQueueName += uriPath;
+ }
+
+ InitialContext context = new InitialContext();
+ QueueConnectionFactory connectionFactory =
(QueueConnectionFactory)context.lookup("ConnectionFactory");
+ Queue reqQueue = (Queue)context.lookup(reqQueueName);
+
+ QueueConnection con = connectionFactory.createQueueConnection();
+ QueueSession session = con.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
+ con.start();
+
+ ByteArrayOutputStream output = new ByteArrayOutputStream();
+ getMarshaller().write(reqMessage, output);
+ BytesMessage message = session.createBytesMessage();
+ message.writeBytes(output.toByteArray());
+
+ ResponseListener responseListener = null;
+ if (oneway == false)
+ {
+ String resQueueName = getURLProperty(jmsURI, "replyToName");
+ Queue resQueue = (Queue)context.lookup(resQueueName);
+ QueueReceiver receiver = session.createReceiver(resQueue);
+ responseListener = new ResponseListener();
+ receiver.setMessageListener(responseListener);
+ message.setJMSReplyTo(resQueue);
+ waitForResponse = true;
+ }
+
+ QueueSender sender = session.createSender(reqQueue);
+ sender.send(message);
+ sender.close();
+
+ MessageAbstraction resMessage = null;
+ if (responseListener != null)
+ {
+ int timeout = 5000;
+ while (waitForResponse && timeout > 0)
+ {
+ Thread.sleep(100);
+ timeout -= 100;
+ }
+
+ ByteArrayInputStream bais = new
ByteArrayInputStream(responseListener.resMessage.getBytes());
+ resMessage = (MessageAbstraction)getUnmarshaller().read(bais, null);
+ }
+
+ con.stop();
+ session.close();
+ con.close();
+
+ return resMessage;
+ }
+ catch (RuntimeException ex)
+ {
+ throw ex;
+ }
+ catch (Exception ex)
+ {
+ IOException ioex = new IOException(ex.getMessage());
+ ioex.initCause(ex);
+ throw ioex;
+ }
+ }
+
+ private String getURLProperty(URI uri, String key)
+ {
+ String retValue = null;
+ String query = uri.getQuery();
+ if (query != null)
+ {
+ StringTokenizer st = new StringTokenizer(query, "?:=");
+ while (retValue == null && st.hasMoreTokens())
+ {
+ String propName = st.nextToken();
+ String propValue = st.nextToken();
+ if (propName.equals(key))
+ retValue = propValue;
+ }
+ }
+ return retValue;
+ }
+
+ public class ResponseListener implements MessageListener
+ {
+ public String resMessage;
+
+ public void onMessage(Message msg)
+ {
+ TextMessage textMessage = (TextMessage)msg;
+ try
+ {
+ resMessage = textMessage.getText();
+ waitForResponse = false;
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace();
+ }
+ }
+ }
+}
Property changes on:
stack/native/trunk/src/main/java/org/jboss/ws/core/client/SOAPProtocolConnectionJMS.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Deleted:
stack/native/trunk/src/main/java/org/jboss/ws/core/client/SOAPRemotingConnection.java
===================================================================
---
stack/native/trunk/src/main/java/org/jboss/ws/core/client/SOAPRemotingConnection.java 2008-01-10
12:21:02 UTC (rev 5455)
+++
stack/native/trunk/src/main/java/org/jboss/ws/core/client/SOAPRemotingConnection.java 2008-01-10
14:16:57 UTC (rev 5456)
@@ -1,120 +0,0 @@
-/*
- * 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.ws.core.client;
-
-// $Id$
-
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Properties;
-
-import javax.xml.soap.MimeHeader;
-import javax.xml.soap.MimeHeaders;
-import javax.xml.soap.SOAPException;
-import javax.xml.soap.SOAPMessage;
-
-import org.jboss.remoting.marshal.Marshaller;
-import org.jboss.remoting.marshal.UnMarshaller;
-import org.jboss.ws.WSException;
-import org.jboss.ws.core.MessageAbstraction;
-import org.jboss.ws.core.soap.SOAPMessageMarshaller;
-import org.jboss.ws.core.soap.SOAPMessageUnMarshaller;
-import org.jboss.ws.extensions.xop.XOPContext;
-
-/**
- * SOAPConnection implementation
- *
- * @author Thomas.Diesler(a)jboss.org
- * @author <a href="mailto:jason@stacksmash.com">Jason T.
Greene</a>
- *
- * @since 02-Apr-2007
- */
-public class SOAPRemotingConnection extends RemotingConnectionImpl
-{
- protected UnMarshaller getUnmarshaller()
- {
- return new SOAPMessageUnMarshaller();
- }
-
- protected Marshaller getMarshaller()
- {
- return new SOAPMessageMarshaller();
- }
-
- public MessageAbstraction invoke(MessageAbstraction reqMessage, Object endpoint,
boolean oneway) throws IOException
- {
- try
- {
- // enforce xop transitions
- // TODO: there should be a clear transition to an immutable object model
- XOPContext.eagerlyCreateAttachments();
-
- // save object model changes
- SOAPMessage soapMessage = (SOAPMessage)reqMessage;
- if (reqMessage != null && soapMessage.saveRequired())
- soapMessage.saveChanges();
-
- return super.invoke(reqMessage, endpoint, oneway);
- }
- catch (SOAPException ex)
- {
- IOException io = new IOException();
- io.initCause(ex);
- throw io;
- }
- }
-
- protected void populateHeaders(MessageAbstraction reqMessage, Map<String,
Object> metadata)
- {
- super.populateHeaders(reqMessage, metadata);
-
- Properties props = (Properties)metadata.get("HEADER");
-
- // R2744 A HTTP request MESSAGE MUST contain a SOAPAction HTTP header field
- // with a quoted value equal to the value of the soapAction attribute of
- // soapbind:operation, if present in the corresponding WSDL description.
-
- // R2745 A HTTP request MESSAGE MUST contain a SOAPAction HTTP header field
- // with a quoted empty string value, if in the corresponding WSDL description,
- // the soapAction attribute of soapbind:operation is either not present, or
- // present with an empty string as its value.
-
- MimeHeaders mimeHeaders = reqMessage.getMimeHeaders();
- String[] action = mimeHeaders.getHeader("SOAPAction");
- if (action != null && action.length > 0)
- {
- String soapAction = action[0];
-
- // R1109 The value of the SOAPAction HTTP header field in a HTTP request MESSAGE
MUST be a quoted string.
- if (soapAction.startsWith("\"") == false ||
soapAction.endsWith("\"") == false)
- soapAction = "\"" + soapAction + "\"";
-
- props.put("SOAPAction", soapAction);
- }
- else
- {
- props.put("SOAPAction", "\"\"");
- }
-
- }
-}
Modified:
stack/native/trunk/src/main/java/org/jboss/ws/core/jaxws/client/DispatchImpl.java
===================================================================
---
stack/native/trunk/src/main/java/org/jboss/ws/core/jaxws/client/DispatchImpl.java 2008-01-10
12:21:02 UTC (rev 5455)
+++
stack/native/trunk/src/main/java/org/jboss/ws/core/jaxws/client/DispatchImpl.java 2008-01-10
14:16:57 UTC (rev 5456)
@@ -60,9 +60,9 @@
import org.jboss.ws.core.ConfigProvider;
import org.jboss.ws.core.MessageAbstraction;
import org.jboss.ws.core.client.EndpointInfo;
-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.client.HTTPProtocolConnection;
+import org.jboss.ws.core.client.RemoteConnection;
+import org.jboss.ws.core.client.SOAPProtocolConnectionHTTP;
import org.jboss.ws.core.jaxws.binding.BindingExt;
import org.jboss.ws.core.jaxws.binding.BindingProviderImpl;
import org.jboss.ws.core.jaxws.handler.HandlerChainExecutor;
@@ -280,20 +280,20 @@
return retObj;
}
- private RemotingConnection getRemotingConnection()
+ private RemoteConnection getRemotingConnection()
{
String bindingID = ((Binding21)bindingProvider.getBinding()).getBindingID();
if (EndpointMetaData.SUPPORTED_BINDINGS.contains(bindingID) == false)
throw new IllegalStateException("Unsupported binding: " + bindingID);
- RemotingConnection remotingConnection;
+ RemoteConnection remotingConnection;
if (HTTPBinding.HTTP_BINDING.equals(bindingID))
{
- remotingConnection = new HTTPRemotingConnection();
+ remotingConnection = new HTTPProtocolConnection();
}
else
{
- remotingConnection = new SOAPRemotingConnection();
+ remotingConnection = new SOAPProtocolConnectionHTTP();
}
return remotingConnection;
}
Modified: stack/native/trunk/src/main/java/org/jboss/ws/core/soap/SOAPConnectionImpl.java
===================================================================
---
stack/native/trunk/src/main/java/org/jboss/ws/core/soap/SOAPConnectionImpl.java 2008-01-10
12:21:02 UTC (rev 5455)
+++
stack/native/trunk/src/main/java/org/jboss/ws/core/soap/SOAPConnectionImpl.java 2008-01-10
14:16:57 UTC (rev 5456)
@@ -23,16 +23,14 @@
// $Id$
-import java.io.IOException;
-
import javax.xml.soap.SOAPConnection;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPMessage;
import org.jboss.logging.Logger;
import org.jboss.ws.core.MessageAbstraction;
-import org.jboss.ws.core.client.RemotingConnectionImpl;
-import org.jboss.ws.core.client.SOAPRemotingConnection;
+import org.jboss.ws.core.client.HTTPRemotingConnection;
+import org.jboss.ws.core.client.SOAPProtocolConnectionHTTP;
/**
* SOAPConnection implementation
@@ -47,11 +45,11 @@
// provide logging
private static Logger log = Logger.getLogger(SOAPConnectionImpl.class);
- private RemotingConnectionImpl remotingConnection;
+ private HTTPRemotingConnection remotingConnection;
public SOAPConnectionImpl()
{
- remotingConnection = new SOAPRemotingConnection();
+ remotingConnection = new SOAPProtocolConnectionHTTP();
}
/**
Modified:
stack/native/trunk/src/main/java/org/jboss/ws/core/soap/SOAPMessageUnMarshaller.java
===================================================================
---
stack/native/trunk/src/main/java/org/jboss/ws/core/soap/SOAPMessageUnMarshaller.java 2008-01-10
12:21:02 UTC (rev 5455)
+++
stack/native/trunk/src/main/java/org/jboss/ws/core/soap/SOAPMessageUnMarshaller.java 2008-01-10
14:16:57 UTC (rev 5456)
@@ -25,20 +25,13 @@
import java.io.IOException;
import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
import java.util.Map;
-import javax.servlet.http.HttpServletResponse;
-import javax.xml.soap.MimeHeaders;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPMessage;
import org.jboss.logging.Logger;
import org.jboss.remoting.marshal.UnMarshaller;
-import org.jboss.remoting.transport.http.HTTPMetadataConstants;
-import org.jboss.ws.WSException;
/**
* @author Thomas.Diesler(a)jboss.org
@@ -49,15 +42,6 @@
// Provide logging
private static Logger log = Logger.getLogger(SOAPMessageUnMarshaller.class);
- private static List validResponseCodes = new ArrayList();
- static
- {
- validResponseCodes.add(HttpServletResponse.SC_OK);
- validResponseCodes.add(HttpServletResponse.SC_ACCEPTED);
- validResponseCodes.add(HttpServletResponse.SC_NO_CONTENT);
- validResponseCodes.add(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
- }
-
public Object read(InputStream inputStream, Map metadata) throws IOException,
ClassNotFoundException
{
if (log.isTraceEnabled())
@@ -65,25 +49,8 @@
try
{
- Integer resCode = (Integer)metadata.get(HTTPMetadataConstants.RESPONSE_CODE);
- if (resCode == null)
- {
- log.warn("No HTTP resonse code, assuming: SC_OK");
- resCode = HttpServletResponse.SC_OK;
- }
-
- String resMessage =
(String)metadata.get(HTTPMetadataConstants.RESPONSE_CODE_MESSAGE);
- if (validResponseCodes.contains(resCode) == false)
- throw new WSException("Invalid HTTP server response [" + resCode +
"] - " + resMessage);
+ SOAPMessage soapMsg = new MessageFactoryImpl().createMessage(null, inputStream,
true);
- // [JBWS-859] SOAPMessageUnMarshaller doesn't support HTTP server response
[204] - No Content
- SOAPMessage soapMsg = null;
- if (resCode != HttpServletResponse.SC_NO_CONTENT)
- {
- MimeHeaders mimeHeaders = getMimeHeaders(metadata);
- soapMsg = new MessageFactoryImpl().createMessage(mimeHeaders, inputStream,
true);
- }
-
return soapMsg;
}
catch (SOAPException e)
@@ -95,42 +62,12 @@
}
}
- /**
- * Set the class loader to use for unmarhsalling. This may
- * be needed when need to have access to class definitions that
- * are not part of this unmarshaller's parent classloader (especially
- * when doing remote classloading).
- *
- * @param classloader
- */
public void setClassLoader(ClassLoader classloader)
{
- //NO OP
}
public UnMarshaller cloneUnMarshaller() throws CloneNotSupportedException
{
return new SOAPMessageUnMarshaller();
}
-
- private MimeHeaders getMimeHeaders(Map metadata)
- {
- log.debug("getMimeHeaders from: " + metadata);
-
- MimeHeaders headers = new MimeHeaders();
- Iterator i = metadata.keySet().iterator();
- while (i.hasNext())
- {
- String key = (String)i.next();
- Object value = metadata.get(key);
- if (key != null && value instanceof List)
- {
- for (Object listValue : (List)value)
- {
- headers.addHeader(key, listValue.toString());
- }
- }
- }
- return headers;
- }
}
Copied:
stack/native/trunk/src/main/java/org/jboss/ws/core/soap/SOAPMessageUnMarshallerHTTP.java
(from rev 5449,
stack/native/trunk/src/main/java/org/jboss/ws/core/soap/SOAPMessageUnMarshaller.java)
===================================================================
---
stack/native/trunk/src/main/java/org/jboss/ws/core/soap/SOAPMessageUnMarshallerHTTP.java
(rev 0)
+++
stack/native/trunk/src/main/java/org/jboss/ws/core/soap/SOAPMessageUnMarshallerHTTP.java 2008-01-10
14:16:57 UTC (rev 5456)
@@ -0,0 +1,136 @@
+/*
+ * 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.ws.core.soap;
+
+// $Id$
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletResponse;
+import javax.xml.soap.MimeHeaders;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPMessage;
+
+import org.jboss.logging.Logger;
+import org.jboss.remoting.marshal.UnMarshaller;
+import org.jboss.remoting.transport.http.HTTPMetadataConstants;
+import org.jboss.ws.WSException;
+
+/**
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 25-Nov-2004
+ */
+public class SOAPMessageUnMarshallerHTTP implements UnMarshaller
+{
+ // Provide logging
+ private static Logger log = Logger.getLogger(SOAPMessageUnMarshallerHTTP.class);
+
+ private static List validResponseCodes = new ArrayList();
+ static
+ {
+ validResponseCodes.add(HttpServletResponse.SC_OK);
+ validResponseCodes.add(HttpServletResponse.SC_ACCEPTED);
+ validResponseCodes.add(HttpServletResponse.SC_NO_CONTENT);
+ validResponseCodes.add(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+ }
+
+ public Object read(InputStream inputStream, Map metadata) throws IOException,
ClassNotFoundException
+ {
+ if (log.isTraceEnabled())
+ log.trace("Read input stream with metadata=" + metadata);
+
+ try
+ {
+ Integer resCode = (Integer)metadata.get(HTTPMetadataConstants.RESPONSE_CODE);
+ if (resCode == null)
+ {
+ log.warn("No HTTP resonse code, assuming: SC_OK");
+ resCode = HttpServletResponse.SC_OK;
+ }
+
+ String resMessage =
(String)metadata.get(HTTPMetadataConstants.RESPONSE_CODE_MESSAGE);
+ if (validResponseCodes.contains(resCode) == false)
+ throw new WSException("Invalid HTTP server response [" + resCode +
"] - " + resMessage);
+
+ // [JBWS-859] SOAPMessageUnMarshaller doesn't support HTTP server response
[204] - No Content
+ SOAPMessage soapMsg = null;
+ if (resCode != HttpServletResponse.SC_NO_CONTENT)
+ {
+ MimeHeaders mimeHeaders = getMimeHeaders(metadata);
+ soapMsg = new MessageFactoryImpl().createMessage(mimeHeaders, inputStream,
true);
+ }
+
+ return soapMsg;
+ }
+ catch (SOAPException e)
+ {
+ log.error("Cannot unmarshall SOAPMessage", e);
+ IOException e2 = new IOException(e.toString());
+ e2.initCause(e);
+ throw e2;
+ }
+ }
+
+ /**
+ * Set the class loader to use for unmarhsalling. This may
+ * be needed when need to have access to class definitions that
+ * are not part of this unmarshaller's parent classloader (especially
+ * when doing remote classloading).
+ *
+ * @param classloader
+ */
+ public void setClassLoader(ClassLoader classloader)
+ {
+ //NO OP
+ }
+
+ public UnMarshaller cloneUnMarshaller() throws CloneNotSupportedException
+ {
+ return new SOAPMessageUnMarshallerHTTP();
+ }
+
+ private MimeHeaders getMimeHeaders(Map metadata)
+ {
+ log.debug("getMimeHeaders from: " + metadata);
+
+ MimeHeaders headers = new MimeHeaders();
+ Iterator i = metadata.keySet().iterator();
+ while (i.hasNext())
+ {
+ String key = (String)i.next();
+ Object value = metadata.get(key);
+ if (key != null && value instanceof List)
+ {
+ for (Object listValue : (List)value)
+ {
+ headers.addHeader(key, listValue.toString());
+ }
+ }
+ }
+ return headers;
+ }
+}
Added:
stack/native/trunk/src/main/resources/jbossws-core.jar/META-INF/services/org.jboss.ws.core.client.RemoteConnection.http
===================================================================
---
stack/native/trunk/src/main/resources/jbossws-core.jar/META-INF/services/org.jboss.ws.core.client.RemoteConnection.http
(rev 0)
+++
stack/native/trunk/src/main/resources/jbossws-core.jar/META-INF/services/org.jboss.ws.core.client.RemoteConnection.http 2008-01-10
14:16:57 UTC (rev 5456)
@@ -0,0 +1 @@
+org.jboss.ws.core.client.SOAPProtocolConnectionHTTP
\ No newline at end of file
Added:
stack/native/trunk/src/main/resources/jbossws-core.jar/META-INF/services/org.jboss.ws.core.client.RemoteConnection.jms
===================================================================
---
stack/native/trunk/src/main/resources/jbossws-core.jar/META-INF/services/org.jboss.ws.core.client.RemoteConnection.jms
(rev 0)
+++
stack/native/trunk/src/main/resources/jbossws-core.jar/META-INF/services/org.jboss.ws.core.client.RemoteConnection.jms 2008-01-10
14:16:57 UTC (rev 5456)
@@ -0,0 +1 @@
+org.jboss.ws.core.client.SOAPProtocolConnectionJMS
\ No newline at end of file
Modified:
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/jmstransport/JMSTransportTestCase.java
===================================================================
---
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/jmstransport/JMSTransportTestCase.java 2008-01-10
12:21:02 UTC (rev 5455)
+++
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/jmstransport/JMSTransportTestCase.java 2008-01-10
14:16:57 UTC (rev 5456)
@@ -8,6 +8,9 @@
// $Id$
+import java.io.File;
+import java.net.URL;
+
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.Queue;
@@ -19,6 +22,8 @@
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.InitialContext;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
import org.jboss.wsf.test.JBossWSTest;
import org.jboss.wsf.test.JBossWSTestSetup;
@@ -42,11 +47,34 @@
return new JBossWSTestSetup(JMSTransportTestCase.class,
"jaxws-samples-jmstransport.sar");
}
- /**
- * Send the message to the specified queue
- */
- public void testSOAPMessageToEndpointQueue() throws Exception
+ public void testJMSEndpointPort() throws Exception
{
+ URL wsdlURL = new
File("resources/jaxws/samples/jmstransport/jmsservice.wsdl").toURL();
+ QName serviceName = new QName("http://org.jboss.ws/samples/jmstransport",
"OrganizationJMSEndpointService");
+ QName portName = new QName("http://org.jboss.ws/samples/jmstransport",
"JMSEndpointPort");
+
+ Service service = Service.create(wsdlURL, serviceName);
+ Organization port = service.getPort(portName, Organization.class);
+
+ String res = port.getContactInfo("mafia");
+ assertEquals("The 'mafia' boss is currently out of office, please call
again.", res);
+ }
+
+ public void testHTTPEndpointPort() throws Exception
+ {
+ URL wsdlURL = new
File("resources/jaxws/samples/jmstransport/jmsservice.wsdl").toURL();
+ QName serviceName = new QName("http://org.jboss.ws/samples/jmstransport",
"OrganizationJMSEndpointService");
+ QName portName = new QName("http://org.jboss.ws/samples/jmstransport",
"HTTPEndpointPort");
+
+ Service service = Service.create(wsdlURL, serviceName);
+ Organization port = service.getPort(portName, Organization.class);
+
+ String res = port.getContactInfo("mafia");
+ assertEquals("The 'mafia' boss is currently out of office, please call
again.", res);
+ }
+
+ public void testMessagingClient() throws Exception
+ {
String reqMessage =
"<env:Envelope
xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>" +
"<env:Body>" +
Modified:
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/jmstransport/Organization.java
===================================================================
---
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/jmstransport/Organization.java 2008-01-10
12:21:02 UTC (rev 5455)
+++
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/jmstransport/Organization.java 2008-01-10
14:16:57 UTC (rev 5456)
@@ -1,34 +1,32 @@
/*
- * 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.
- */
+ * 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.samples.jmstransport;
-import java.rmi.Remote;
-
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
@WebService
@SOAPBinding(style = SOAPBinding.Style.RPC)
-public interface Organization extends Remote
+public interface Organization
{
String getContactInfo(String organization);
}
Modified:
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/jmstransport/OrganizationJMSEndpoint.java
===================================================================
---
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/jmstransport/OrganizationJMSEndpoint.java 2008-01-10
12:21:02 UTC (rev 5455)
+++
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/samples/jmstransport/OrganizationJMSEndpoint.java 2008-01-10
14:16:57 UTC (rev 5456)
@@ -12,12 +12,14 @@
import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
+import javax.jms.Message;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import org.jboss.logging.Logger;
import org.jboss.ws.core.transport.jms.JMSTransportSupportEJB3;
+import org.jboss.wsf.spi.annotation.WebContext;
/**
* An example of a MDB acting as a web service endpoint.
@@ -26,6 +28,7 @@
* @since 09-Jan-2008
*/
@WebService (targetNamespace = "http://org.jboss.ws/samples/jmstransport")
+@WebContext (contextRoot = "/jaxws-samples-jmstransport")
@SOAPBinding(style = SOAPBinding.Style.RPC)
@MessageDriven(activationConfig = {
@@ -42,4 +45,11 @@
log.info("getContactInfo: " + organization);
return "The '" + organization + "' boss is currently out of
office, please call again.";
}
+
+ @Override
+ public void onMessage(Message message)
+ {
+ log.info("onMessage: " + message);
+ super.onMessage(message);
+ }
}
Added: stack/native/trunk/src/test/resources/jaxws/samples/jmstransport/jmsservice.wsdl
===================================================================
--- stack/native/trunk/src/test/resources/jaxws/samples/jmstransport/jmsservice.wsdl
(rev 0)
+++
stack/native/trunk/src/test/resources/jaxws/samples/jmstransport/jmsservice.wsdl 2008-01-10
14:16:57 UTC (rev 5456)
@@ -0,0 +1,55 @@
+<definitions name='OrganizationJMSEndpointService'
targetNamespace='http://org.jboss.ws/samples/jmstransport'
xmlns='http://schemas.xmlsoap.org/wsdl/'
+
xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
xmlns:tns='http://org.jboss.ws/samples/jmstransport'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
+
+ <types></types>
+
+ <message name='OrganizationJMSEndpoint_getContactInfoResponse'>
+ <part name='return' type='xsd:string'></part>
+ </message>
+ <message name='OrganizationJMSEndpoint_getContactInfo'>
+ <part name='arg0' type='xsd:string'></part>
+ </message>
+
+ <portType name='OrganizationJMSEndpoint'>
+ <operation name='getContactInfo' parameterOrder='arg0'>
+ <input
message='tns:OrganizationJMSEndpoint_getContactInfo'></input>
+ <output
message='tns:OrganizationJMSEndpoint_getContactInfoResponse'></output>
+ </operation>
+ </portType>
+
+ <binding name='HTTPBinding' type='tns:OrganizationJMSEndpoint'>
+ <soap:binding style='rpc'
transport='http://schemas.xmlsoap.org/soap/http'/>
+ <operation name='getContactInfo'>
+ <soap:operation soapAction=''/>
+ <input>
+ <soap:body namespace='http://org.jboss.ws/samples/jmstransport'
use='literal'/>
+ </input>
+ <output>
+ <soap:body namespace='http://org.jboss.ws/samples/jmstransport'
use='literal'/>
+ </output>
+ </operation>
+ </binding>
+
+ <binding name='JMSBinding' type='tns:OrganizationJMSEndpoint'>
+ <soap:binding style='rpc'
transport='http://www.example.org/2006/06/soap/bindings/JMS/'/>
+ <operation name='getContactInfo'>
+ <soap:operation soapAction=''/>
+ <input>
+ <soap:body namespace='http://org.jboss.ws/samples/jmstransport'
use='literal'/>
+ </input>
+ <output>
+ <soap:body namespace='http://org.jboss.ws/samples/jmstransport'
use='literal'/>
+ </output>
+ </operation>
+ </binding>
+
+ <service name='OrganizationJMSEndpointService'>
+ <port binding='tns:HTTPBinding' name='HTTPEndpointPort'>
+ <soap:address
location='http://@jboss.bind.address@:8080/jaxws-samples-jmstransport/OrganizationJMSEndpoint'/>
+ </port>
+ <port binding='tns:JMSBinding' name='JMSEndpointPort'>
+ <soap:address
location='jms://queue/RequestQueue?replyToName=queue/ResponseQueue'/>
+ </port>
+ </service>
+
+</definitions>
\ No newline at end of file
Property changes on:
stack/native/trunk/src/test/resources/jaxws/samples/jmstransport/jmsservice.wsdl
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF