You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by di...@apache.org on 2006/04/20 20:31:04 UTC
svn commit: r395668 [1/2] - in /webservices/axis2/trunk/java/modules:
core/src/org/apache/axis2/context/ core/src/org/apache/axis2/description/
core/src/org/apache/axis2/engine/ core/src/org/apache/axis2/transport/jms/
integration/ integration/test/org...
Author: dims
Date: Thu Apr 20 11:31:02 2006
New Revision: 395668
URL: http://svn.apache.org/viewcvs?rev=395668&view=rev
Log:
- Fix spelling error in method name (getERPforService -> getEPRforService)
- Add a repo for JMS server and JMS client based tests
- All the 4 tests in JMSEchoRawXMLTest are now working.
Added:
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/jms/jms-enabled-client-axis2.xml
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/jms/jms-enabled-server-axis2.xml
Modified:
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ServiceContext.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/OutInAxisOperation.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/ListenerManager.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/JMSSender.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/SimpleJMSListener.java
webservices/axis2/trunk/java/modules/integration/maven.xml
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/integration/UtilServer.java
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/integration/UtilsJMSServer.java
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/jms/JMSEchoRawXMLTest.java
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ServiceContext.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ServiceContext.java?rev=395668&r1=395667&r2=395668&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ServiceContext.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ServiceContext.java Thu Apr 20 11:31:02 2006
@@ -91,7 +91,7 @@
}
}
if (!lm.isStopped()) {
- return lm.getERPforService(axisService.getName(), null, transport);
+ return lm.getEPRforService(axisService.getName(), null, transport);
}
}
return null;
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/OutInAxisOperation.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/OutInAxisOperation.java?rev=395668&r1=395667&r2=395668&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/OutInAxisOperation.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/OutInAxisOperation.java Thu Apr 20 11:31:02 2006
@@ -247,7 +247,7 @@
.getMessageReceiver();
callbackReceiver.addCallback(mc.getMessageID(), callback);
EndpointReference replyToFromTransport = mc.getConfigurationContext().getListenerManager().
- getERPforService(sc.getAxisService().getName(), axisOp.getName().getLocalPart(), mc
+ getEPRforService(sc.getAxisService().getName(), axisOp.getName().getLocalPart(), mc
.getTransportIn().getName()
.getLocalPart());
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/ListenerManager.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/ListenerManager.java?rev=395668&r1=395667&r2=395668&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/ListenerManager.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/ListenerManager.java Thu Apr 20 11:31:02 2006
@@ -57,8 +57,8 @@
* @param tranportName : name of the trasport can be null , if it is null then
* @return String
*/
- public synchronized EndpointReference getERPforService(String serviceName, String opName,
- String tranportName) throws AxisFault {
+ public synchronized EndpointReference getEPRforService(String serviceName, String opName,
+ String tranportName) throws AxisFault {
if (tranportName == null || "".equals(tranportName)) {
AxisService service = configctx.getAxisConfiguration().getService(serviceName);
if (service == null) {
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/JMSSender.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/JMSSender.java?rev=395668&r1=395667&r2=395668&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/JMSSender.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/JMSSender.java Thu Apr 20 11:31:02 2006
@@ -1,499 +1,501 @@
-/*
-* Copyright 2001, 2002,2004 The Apache Software Foundation.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-
-package org.apache.axis2.transport.jms;
-
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMOutputFormat;
-import org.apache.axiom.soap.SOAPEnvelope;
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.Constants;
-import org.apache.axis2.client.Options;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.context.OperationContext;
-import org.apache.axis2.description.Parameter;
-import org.apache.axis2.description.TransportOutDescription;
-import org.apache.axis2.handlers.AbstractHandler;
-import org.apache.axis2.i18n.Messages;
-import org.apache.axis2.transport.TransportSender;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.jms.Destination;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-/**
- * This is meant to be used on a SOAP Client to call a SOAP server.
- */
-public class JMSSender extends AbstractHandler implements TransportSender {
-
- private static final long serialVersionUID = -3883554138407525394L;
-
- protected static Log log = LogFactory.getLog(JMSSender.class.getName());
-
- static {
-
- // add a shutdown hook to close JMS connections
- Runtime.getRuntime().addShutdownHook(new Thread() {
- public void run() {
- JMSSender.closeAllConnectors();
- }
- });
- }
-
- HashMap params = new HashMap();
-
- public JMSSender() {
- }
-
- public void cleanUp(MessageContext msgContext) throws AxisFault {
- }
-
- /**
- * Closes all JMS connectors
- */
- public static void closeAllConnectors() {
- if (log.isDebugEnabled()) {
- log.debug("Enter: JMSTransport::closeAllConnectors");
- }
-
- JMSConnectorManager.getInstance().closeAllConnectors();
-
- if (log.isDebugEnabled()) {
- log.debug("Exit: JMSTransport::closeAllConnectors");
- }
- }
-
- /**
- * Closes JMS connectors that match the specified endpoint address
- *
- * @param endpointAddr the JMS endpoint address
- * @param username
- * @param password
- */
- public static void closeMatchingJMSConnectors(String endpointAddr, String username,
- String password) {
- if (log.isDebugEnabled()) {
- log.debug("Enter: JMSTransport::closeMatchingJMSConnectors");
- }
-
- try {
- JMSURLHelper jmsurl = new JMSURLHelper(endpointAddr);
- String vendorId = jmsurl.getVendor();
- JMSVendorAdapter vendorAdapter = null;
-
- if (vendorId == null) {
- vendorId = JMSConstants.JNDI_VENDOR_ID;
- }
-
- vendorAdapter = JMSVendorAdapterFactory.getJMSVendorAdapter(vendorId);
-
- // the vendor adapter may not exist
- if (vendorAdapter == null) {
- return;
- }
-
- // determine the set of properties to be used for matching the connection
- HashMap connectorProps = vendorAdapter.getJMSConnectorProperties(jmsurl);
- HashMap cfProps = vendorAdapter.getJMSConnectionFactoryProperties(jmsurl);
-
- JMSConnectorManager.getInstance().closeMatchingJMSConnectors(connectorProps, cfProps,
- username, password, vendorAdapter);
- } catch (Exception e) {
- log.warn(Messages.getMessage("malformedURLException00"), e);
- }
-
- if (log.isDebugEnabled()) {
- log.debug("Exit: JMSTransport::closeMatchingJMSConnectors");
- }
- }
-
- /**
- * Return a map of properties that makeup the application-specific
- * for the JMS Messages.
- */
- protected HashMap createApplicationProperties(MessageContext context) {
- HashMap props = new HashMap();
-
- if (context.getProperty(JMSConstants.JMS_APPLICATION_MSG_PROPS) != null) {
- props.putAll((Map) context.getProperty(JMSConstants.JMS_APPLICATION_MSG_PROPS));
- }
-
- return props;
- }
-
- private HashMap createSendProperties(MessageContext context) {
-
- // I'm not sure why this helper method is private, but
- // we need to delegate to factory method that can build the
- // application-specific map of properties so make a change to
- // delegate here.
- HashMap props = createApplicationProperties(context);
-
- if (context.getProperty(JMSConstants.PRIORITY) != null) {
- props.put(JMSConstants.PRIORITY, context.getProperty(JMSConstants.PRIORITY));
- }
-
- if (context.getProperty(JMSConstants.DELIVERY_MODE) != null) {
- props.put(JMSConstants.DELIVERY_MODE, context.getProperty(JMSConstants.DELIVERY_MODE));
- }
-
- if (context.getProperty(JMSConstants.TIME_TO_LIVE) != null) {
- props.put(JMSConstants.TIME_TO_LIVE, context.getProperty(JMSConstants.TIME_TO_LIVE));
- }
-
- if (context.getProperty(JMSConstants.JMS_CORRELATION_ID) != null) {
- props.put(JMSConstants.JMS_CORRELATION_ID,
- context.getProperty(JMSConstants.JMS_CORRELATION_ID));
- }
-
- return props;
- }
-
- public void init(ConfigurationContext confContext, TransportOutDescription transportOut)
- throws AxisFault {
- Iterator iterator = transportOut.getParameters().iterator();
-
- while (iterator.hasNext()) {
- Parameter param = (Parameter) iterator.next();
-
- params.put(param.getName(), param.getValue());
- }
- }
-
- /**
- * invoke() creates an endpoint, sends the request SOAP message, and then
- * either reads the response SOAP message or simply returns.
- *
- * @param msgContext
- * @throws AxisFault
- */
- public void invoke(MessageContext msgContext) throws AxisFault {
- JMSConnector connector = null;
- HashMap properties = null;
- Destination dest = null;
-
- if (msgContext.isServerSide()) {
- JMSOutTransportInfo transportInfo =
- (JMSOutTransportInfo) msgContext.getProperty(Constants.OUT_TRANSPORT_INFO);
-
- if (transportInfo != null) {
- dest = transportInfo.getDestination();
- properties = transportInfo.getProperties();
- }
- }
-
- String endpointAddress = msgContext.getTo() != null ? msgContext.getTo().getAddress() : null;
- boolean waitForResponse = false;
-
- if (dest == null) {
- if ((msgContext
- .getProperty(Constants.Configuration
- .IS_USING_SEPARATE_LISTENER) != null) && msgContext
- .getProperty(Constants.Configuration.IS_USING_SEPARATE_LISTENER)
- .equals(Boolean.TRUE)) {
- waitForResponse = !((Boolean) msgContext.getProperty(
- Constants.Configuration.IS_USING_SEPARATE_LISTENER)).booleanValue();
- } else {
- waitForResponse = !msgContext.getOptions().isUseSeparateListener();
- }
- } else {
- if (properties != null) {
- JMSURLHelper url = null;
-
- try {
- url = new JMSURLHelper("jms:/" + dest);
- } catch (Exception e) {
- throw AxisFault.makeFault(e);
- }
-
- url.getProperties().putAll(properties);
- endpointAddress = url.getURLString();
- }
- }
-
- setupTransport(msgContext, endpointAddress);
-
- if (connector == null) {
- connector = (JMSConnector) msgContext.getProperty(JMSConstants.CONNECTOR);
- }
-
- try {
- JMSEndpoint endpoint = null;
-
- if (dest == null) {
- Object destination = msgContext.getProperty(JMSConstants.DESTINATION);
-
- if ((destination == null) && (msgContext.getTo() != null)) {
- String to = msgContext.getTo().getAddress();
-
- if (to != null) {
- JMSURLHelper url = new JMSURLHelper(to);
-
- destination = url.getDestination();
- }
- }
-
- if (destination == null) {
- throw new AxisFault("noDestination");
- }
-
- if (destination instanceof String) {
- endpoint = connector.createEndpoint((String) destination);
- } else {
- endpoint = connector.createEndpoint((Destination) destination);
- }
- } else {
- endpoint = connector.createEndpoint(dest);
- }
-
- ByteArrayOutputStream out = new ByteArrayOutputStream();
-
- // TODO: How do we fix Attachments?
- writeMessage(msgContext, out);
-
- HashMap props = createSendProperties(msgContext);
-
- props.put("contentType", getContentType(msgContext));
- props.put("SOAPAction", getSOAPAction(msgContext));
-
- if (waitForResponse) {
- long timeout = Options.DEFAULT_TIMEOUT_MILLISECONDS;
-
- if (msgContext.getProperty(JMSConstants.TIMEOUT_TIME) != null) {
- timeout =
- ((Long) msgContext.getProperty(JMSConstants.TIMEOUT_TIME)).longValue();
- }
-
- byte[] response = endpoint.call(out.toByteArray(), timeout, props);
- InputStream in = new ByteArrayInputStream(response);
-
- msgContext.setProperty(MessageContext.TRANSPORT_IN, in);
- } else {
- endpoint.send(out.toByteArray(), props);
- }
- } catch (Exception e) {
- throw new AxisFault("failedSend", e);
- } finally {
- if (connector != null) {
- JMSConnectorManager.getInstance().release(connector);
- }
- }
- }
-
- /**
- * Set up any transport-specific derived properties in the message context.
- *
- * @param context the context to set up
- * @throws AxisFault if service cannot be found
- */
- public void setupTransport(MessageContext context, String endpointAddr) throws AxisFault {
- if (log.isDebugEnabled()) {
- log.debug("Enter: JMSTransport::invoke");
- }
-
- JMSConnector connector = null;
- HashMap connectorProperties = null;
- HashMap connectionFactoryProperties = null;
- JMSVendorAdapter vendorAdapter = null;
- JMSURLHelper jmsurl = null;
-
- // a security context is required to create/use JMSConnectors
- // TODO: Fill username password from context
- String username = "";
- String password = "";
-
- // the presence of an endpoint address indicates whether the client application
- // is instantiating the JMSTransport directly (deprecated) or indirectly via JMS URL
- if (endpointAddr != null) {
- try {
-
- // performs minimal validation ('jms:/destination?...')
- jmsurl = new JMSURLHelper(endpointAddr);
-
- // lookup the appropriate vendor adapter
- String vendorId = jmsurl.getVendor();
-
- if (vendorId == null) {
- vendorId = JMSConstants.JNDI_VENDOR_ID;
- }
-
- if (log.isDebugEnabled()) {
- log.debug("JMSTransport.invoke(): endpt=" + endpointAddr + ", vendor="
- + vendorId);
- }
-
- vendorAdapter = JMSVendorAdapterFactory.getJMSVendorAdapter(vendorId);
-
- if (vendorAdapter == null) {
- throw new AxisFault("cannotLoadAdapterClass:" + vendorId);
- }
-
- // populate the connector and connection factory properties tables
- connectorProperties = vendorAdapter.getJMSConnectorProperties(jmsurl);
- connectionFactoryProperties =
- vendorAdapter.getJMSConnectionFactoryProperties(jmsurl);
- } catch (Exception e) {
- log.error(Messages.getMessage("malformedURLException00"), e);
-
- throw new AxisFault(Messages.getMessage("malformedURLException00"), e);
- }
- } else {
-
- // the JMSTransport was instantiated directly, use the default adapter
- try {
- vendorAdapter = JMSVendorAdapterFactory.getJMSVendorAdapter();
- } catch (Exception e) {
- throw new AxisFault("cannotLoadAdapterClass");
- }
-
- // use the properties passed in to the constructor
- connectorProperties = params;
- connectionFactoryProperties = params;
- }
-
- try {
- connector = JMSConnectorManager.getInstance().getConnector(connectorProperties,
- connectionFactoryProperties, username, password, vendorAdapter);
- } catch (Exception e) {
- log.error(Messages.getMessage("cannotConnectError"), e);
-
- if (e instanceof AxisFault) {
- throw(AxisFault) e;
- }
-
- throw new AxisFault("cannotConnect", e);
- }
-
- // store these in the context for later use
- context.setProperty(JMSConstants.CONNECTOR, connector);
- context.setProperty(JMSConstants.VENDOR_ADAPTER, vendorAdapter);
-
- // vendors may populate the message context
- vendorAdapter.setupMessageContext(context, jmsurl);
-
- if (log.isDebugEnabled()) {
- log.debug("Exit: JMSTransport::invoke");
- }
- }
-
- /**
- * Shuts down the connectors managed by this JMSTransport.
- */
- public void shutdown() {
- if (log.isDebugEnabled()) {
- log.debug("Enter: JMSTransport::shutdown");
- }
-
- closeAllConnectors();
-
- if (log.isDebugEnabled()) {
- log.debug("Exit: JMSTransport::shutdown");
- }
- }
-
- public void writeMessage(MessageContext msgContext, OutputStream out) throws AxisFault {
- SOAPEnvelope envelope = msgContext.getEnvelope();
- OMElement outputMessage = envelope;
-
- if ((envelope != null) && msgContext.isDoingREST()) {
- outputMessage = envelope.getBody().getFirstElement();
- }
-
- if (outputMessage != null) {
- try {
- OMOutputFormat format = new OMOutputFormat();
-
- // Pick the char set encoding from the msgContext
- String charSetEnc =
- (String) msgContext.getProperty(MessageContext.CHARACTER_SET_ENCODING);
-
- format.setDoOptimize(msgContext.isDoingMTOM());
- format.setCharSetEncoding(charSetEnc);
- outputMessage.serializeAndConsume(out, format);
- out.flush();
- } catch (Exception e) {
- throw new AxisFault(e);
- }
- } else {
- throw new AxisFault(Messages.getMessage("outMessageNull"));
- }
- }
-
- public String getContentType(MessageContext msgCtx) {
- OMOutputFormat format = new OMOutputFormat();
- String soapActionString = getSOAPAction(msgCtx);
- String charSetEnc =
- (String) msgCtx.getProperty(MessageContext.CHARACTER_SET_ENCODING);
-
- if (charSetEnc != null) {
- format.setCharSetEncoding(charSetEnc);
- } else {
- OperationContext opctx = msgCtx.getOperationContext();
-
- if (opctx != null) {
- charSetEnc = (String) opctx.getProperty(MessageContext.CHARACTER_SET_ENCODING);
- }
- }
-
- /**
- * If the char set enc is still not found use the default
- */
- if (charSetEnc == null) {
- charSetEnc = MessageContext.DEFAULT_CHAR_SET_ENCODING;
- }
-
- format.setSOAP11(msgCtx.isSOAP11());
- format.setCharSetEncoding(charSetEnc);
-
- String encoding = format.getCharSetEncoding();
- String contentType = format.getContentType();
-
- if (encoding != null) {
- contentType += "; charset=" + encoding;
- }
-
- // action header is not mandated in SOAP 1.2. So putting it, if available
- if (!msgCtx.isSOAP11() && (soapActionString != null)
- && !"".equals(soapActionString.trim())) {
- contentType = contentType + ";action=\"" + soapActionString + "\";";
- }
-
- return contentType;
- }
-
- private String getSOAPAction(MessageContext msgCtx) {
- String soapActionString = msgCtx.getSoapAction();
-
- if ((soapActionString == null) || (soapActionString.length() == 0)) {
- soapActionString = msgCtx.getWSAAction();
- }
-
- if (soapActionString == null) {
- soapActionString = "";
- }
-
- return soapActionString;
- }
-}
+/*
+* Copyright 2001, 2002,2004 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+
+package org.apache.axis2.transport.jms;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMOutputFormat;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.OperationContext;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.description.TransportOutDescription;
+import org.apache.axis2.handlers.AbstractHandler;
+import org.apache.axis2.i18n.Messages;
+import org.apache.axis2.transport.TransportSender;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.jms.Destination;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * This is meant to be used on a SOAP Client to call a SOAP server.
+ */
+public class JMSSender extends AbstractHandler implements TransportSender {
+
+ private static final long serialVersionUID = -3883554138407525394L;
+
+ protected static Log log = LogFactory.getLog(JMSSender.class.getName());
+
+ static {
+
+ // add a shutdown hook to close JMS connections
+ Runtime.getRuntime().addShutdownHook(new Thread() {
+ public void run() {
+ JMSSender.closeAllConnectors();
+ }
+ });
+ }
+
+ HashMap params = new HashMap();
+
+ public JMSSender() {
+ }
+
+ public void cleanUp(MessageContext msgContext) throws AxisFault {
+ }
+
+ /**
+ * Closes all JMS connectors
+ */
+ public static void closeAllConnectors() {
+ if (log.isDebugEnabled()) {
+ log.debug("Enter: JMSTransport::closeAllConnectors");
+ }
+
+ JMSConnectorManager.getInstance().closeAllConnectors();
+
+ if (log.isDebugEnabled()) {
+ log.debug("Exit: JMSTransport::closeAllConnectors");
+ }
+ }
+
+ /**
+ * Closes JMS connectors that match the specified endpoint address
+ *
+ * @param endpointAddr the JMS endpoint address
+ * @param username
+ * @param password
+ */
+ public static void closeMatchingJMSConnectors(String endpointAddr, String username,
+ String password) {
+ if (log.isDebugEnabled()) {
+ log.debug("Enter: JMSTransport::closeMatchingJMSConnectors");
+ }
+
+ try {
+ JMSURLHelper jmsurl = new JMSURLHelper(endpointAddr);
+ String vendorId = jmsurl.getVendor();
+ JMSVendorAdapter vendorAdapter = null;
+
+ if (vendorId == null) {
+ vendorId = JMSConstants.JNDI_VENDOR_ID;
+ }
+
+ vendorAdapter = JMSVendorAdapterFactory.getJMSVendorAdapter(vendorId);
+
+ // the vendor adapter may not exist
+ if (vendorAdapter == null) {
+ return;
+ }
+
+ // determine the set of properties to be used for matching the connection
+ HashMap connectorProps = vendorAdapter.getJMSConnectorProperties(jmsurl);
+ HashMap cfProps = vendorAdapter.getJMSConnectionFactoryProperties(jmsurl);
+
+ JMSConnectorManager.getInstance().closeMatchingJMSConnectors(connectorProps, cfProps,
+ username, password, vendorAdapter);
+ } catch (Exception e) {
+ log.warn(Messages.getMessage("malformedURLException00"), e);
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("Exit: JMSTransport::closeMatchingJMSConnectors");
+ }
+ }
+
+ /**
+ * Return a map of properties that makeup the application-specific
+ * for the JMS Messages.
+ */
+ protected HashMap createApplicationProperties(MessageContext context) {
+ HashMap props = new HashMap();
+
+ if (context.getProperty(JMSConstants.JMS_APPLICATION_MSG_PROPS) != null) {
+ props.putAll((Map) context.getProperty(JMSConstants.JMS_APPLICATION_MSG_PROPS));
+ }
+
+ return props;
+ }
+
+ private HashMap createSendProperties(MessageContext context) {
+
+ // I'm not sure why this helper method is private, but
+ // we need to delegate to factory method that can build the
+ // application-specific map of properties so make a change to
+ // delegate here.
+ HashMap props = createApplicationProperties(context);
+
+ if (context.getProperty(JMSConstants.PRIORITY) != null) {
+ props.put(JMSConstants.PRIORITY, context.getProperty(JMSConstants.PRIORITY));
+ }
+
+ if (context.getProperty(JMSConstants.DELIVERY_MODE) != null) {
+ props.put(JMSConstants.DELIVERY_MODE, context.getProperty(JMSConstants.DELIVERY_MODE));
+ }
+
+ if (context.getProperty(JMSConstants.TIME_TO_LIVE) != null) {
+ props.put(JMSConstants.TIME_TO_LIVE, context.getProperty(JMSConstants.TIME_TO_LIVE));
+ }
+
+ if (context.getProperty(JMSConstants.JMS_CORRELATION_ID) != null) {
+ props.put(JMSConstants.JMS_CORRELATION_ID,
+ context.getProperty(JMSConstants.JMS_CORRELATION_ID));
+ }
+
+ return props;
+ }
+
+ public void init(ConfigurationContext confContext, TransportOutDescription transportOut)
+ throws AxisFault {
+ Iterator iterator = transportOut.getParameters().iterator();
+
+ while (iterator.hasNext()) {
+ Parameter param = (Parameter) iterator.next();
+
+ params.put(param.getName(), param.getValue());
+ }
+ }
+
+ /**
+ * invoke() creates an endpoint, sends the request SOAP message, and then
+ * either reads the response SOAP message or simply returns.
+ *
+ * @param msgContext
+ * @throws AxisFault
+ */
+ public void invoke(MessageContext msgContext) throws AxisFault {
+ JMSConnector connector = null;
+ HashMap properties = null;
+ Destination dest = null;
+
+ if (msgContext.isServerSide()) {
+ JMSOutTransportInfo transportInfo =
+ (JMSOutTransportInfo) msgContext.getProperty(Constants.OUT_TRANSPORT_INFO);
+
+ if (transportInfo != null) {
+ dest = transportInfo.getDestination();
+ properties = transportInfo.getProperties();
+ }
+ }
+
+ String endpointAddress = msgContext.getTo() != null ? msgContext.getTo().getAddress() : null;
+ boolean waitForResponse = false;
+
+ if (dest == null) {
+ if ((msgContext
+ .getProperty(Constants.Configuration
+ .IS_USING_SEPARATE_LISTENER) != null) && msgContext
+ .getProperty(Constants.Configuration.IS_USING_SEPARATE_LISTENER)
+ .equals(Boolean.TRUE)) {
+ waitForResponse = !((Boolean) msgContext.getProperty(
+ Constants.Configuration.IS_USING_SEPARATE_LISTENER)).booleanValue();
+ } else {
+ if(!msgContext.isServerSide()) {
+ waitForResponse = !msgContext.getOptions().isUseSeparateListener();
+ }
+ }
+ } else {
+ if (properties != null) {
+ JMSURLHelper url = null;
+
+ try {
+ url = new JMSURLHelper("jms:/" + dest);
+ } catch (Exception e) {
+ throw AxisFault.makeFault(e);
+ }
+
+ url.getProperties().putAll(properties);
+ endpointAddress = url.getURLString();
+ }
+ }
+
+ setupTransport(msgContext, endpointAddress);
+
+ if (connector == null) {
+ connector = (JMSConnector) msgContext.getProperty(JMSConstants.CONNECTOR);
+ }
+
+ try {
+ JMSEndpoint endpoint = null;
+
+ if (dest == null) {
+ Object destination = msgContext.getProperty(JMSConstants.DESTINATION);
+
+ if ((destination == null) && (msgContext.getTo() != null)) {
+ String to = msgContext.getTo().getAddress();
+
+ if (to != null) {
+ JMSURLHelper url = new JMSURLHelper(to);
+
+ destination = url.getDestination();
+ }
+ }
+
+ if (destination == null) {
+ throw new AxisFault("noDestination");
+ }
+
+ if (destination instanceof String) {
+ endpoint = connector.createEndpoint((String) destination);
+ } else {
+ endpoint = connector.createEndpoint((Destination) destination);
+ }
+ } else {
+ endpoint = connector.createEndpoint(dest);
+ }
+
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+
+ // TODO: How do we fix Attachments?
+ writeMessage(msgContext, out);
+
+ HashMap props = createSendProperties(msgContext);
+
+ props.put("contentType", getContentType(msgContext));
+ props.put("SOAPAction", getSOAPAction(msgContext));
+
+ if (waitForResponse) {
+ long timeout = Options.DEFAULT_TIMEOUT_MILLISECONDS;
+
+ if (msgContext.getProperty(JMSConstants.TIMEOUT_TIME) != null) {
+ timeout =
+ ((Long) msgContext.getProperty(JMSConstants.TIMEOUT_TIME)).longValue();
+ }
+
+ byte[] response = endpoint.call(out.toByteArray(), timeout, props);
+ InputStream in = new ByteArrayInputStream(response);
+
+ msgContext.setProperty(MessageContext.TRANSPORT_IN, in);
+ } else {
+ endpoint.send(out.toByteArray(), props);
+ }
+ } catch (Exception e) {
+ throw new AxisFault("failedSend", e);
+ } finally {
+ if (connector != null) {
+ JMSConnectorManager.getInstance().release(connector);
+ }
+ }
+ }
+
+ /**
+ * Set up any transport-specific derived properties in the message context.
+ *
+ * @param context the context to set up
+ * @throws AxisFault if service cannot be found
+ */
+ public void setupTransport(MessageContext context, String endpointAddr) throws AxisFault {
+ if (log.isDebugEnabled()) {
+ log.debug("Enter: JMSTransport::invoke");
+ }
+
+ JMSConnector connector = null;
+ HashMap connectorProperties = null;
+ HashMap connectionFactoryProperties = null;
+ JMSVendorAdapter vendorAdapter = null;
+ JMSURLHelper jmsurl = null;
+
+ // a security context is required to create/use JMSConnectors
+ // TODO: Fill username password from context
+ String username = "";
+ String password = "";
+
+ // the presence of an endpoint address indicates whether the client application
+ // is instantiating the JMSTransport directly (deprecated) or indirectly via JMS URL
+ if (endpointAddr != null) {
+ try {
+
+ // performs minimal validation ('jms:/destination?...')
+ jmsurl = new JMSURLHelper(endpointAddr);
+
+ // lookup the appropriate vendor adapter
+ String vendorId = jmsurl.getVendor();
+
+ if (vendorId == null) {
+ vendorId = JMSConstants.JNDI_VENDOR_ID;
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("JMSTransport.invoke(): endpt=" + endpointAddr + ", vendor="
+ + vendorId);
+ }
+
+ vendorAdapter = JMSVendorAdapterFactory.getJMSVendorAdapter(vendorId);
+
+ if (vendorAdapter == null) {
+ throw new AxisFault("cannotLoadAdapterClass:" + vendorId);
+ }
+
+ // populate the connector and connection factory properties tables
+ connectorProperties = vendorAdapter.getJMSConnectorProperties(jmsurl);
+ connectionFactoryProperties =
+ vendorAdapter.getJMSConnectionFactoryProperties(jmsurl);
+ } catch (Exception e) {
+ log.error(Messages.getMessage("malformedURLException00"), e);
+
+ throw new AxisFault(Messages.getMessage("malformedURLException00"), e);
+ }
+ } else {
+
+ // the JMSTransport was instantiated directly, use the default adapter
+ try {
+ vendorAdapter = JMSVendorAdapterFactory.getJMSVendorAdapter();
+ } catch (Exception e) {
+ throw new AxisFault("cannotLoadAdapterClass");
+ }
+
+ // use the properties passed in to the constructor
+ connectorProperties = params;
+ connectionFactoryProperties = params;
+ }
+
+ try {
+ connector = JMSConnectorManager.getInstance().getConnector(connectorProperties,
+ connectionFactoryProperties, username, password, vendorAdapter);
+ } catch (Exception e) {
+ log.error(Messages.getMessage("cannotConnectError"), e);
+
+ if (e instanceof AxisFault) {
+ throw(AxisFault) e;
+ }
+
+ throw new AxisFault("cannotConnect", e);
+ }
+
+ // store these in the context for later use
+ context.setProperty(JMSConstants.CONNECTOR, connector);
+ context.setProperty(JMSConstants.VENDOR_ADAPTER, vendorAdapter);
+
+ // vendors may populate the message context
+ vendorAdapter.setupMessageContext(context, jmsurl);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Exit: JMSTransport::invoke");
+ }
+ }
+
+ /**
+ * Shuts down the connectors managed by this JMSTransport.
+ */
+ public void shutdown() {
+ if (log.isDebugEnabled()) {
+ log.debug("Enter: JMSTransport::shutdown");
+ }
+
+ closeAllConnectors();
+
+ if (log.isDebugEnabled()) {
+ log.debug("Exit: JMSTransport::shutdown");
+ }
+ }
+
+ public void writeMessage(MessageContext msgContext, OutputStream out) throws AxisFault {
+ SOAPEnvelope envelope = msgContext.getEnvelope();
+ OMElement outputMessage = envelope;
+
+ if ((envelope != null) && msgContext.isDoingREST()) {
+ outputMessage = envelope.getBody().getFirstElement();
+ }
+
+ if (outputMessage != null) {
+ try {
+ OMOutputFormat format = new OMOutputFormat();
+
+ // Pick the char set encoding from the msgContext
+ String charSetEnc =
+ (String) msgContext.getProperty(MessageContext.CHARACTER_SET_ENCODING);
+
+ format.setDoOptimize(msgContext.isDoingMTOM());
+ format.setCharSetEncoding(charSetEnc);
+ outputMessage.serializeAndConsume(out, format);
+ out.flush();
+ } catch (Exception e) {
+ throw new AxisFault(e);
+ }
+ } else {
+ throw new AxisFault(Messages.getMessage("outMessageNull"));
+ }
+ }
+
+ public String getContentType(MessageContext msgCtx) {
+ OMOutputFormat format = new OMOutputFormat();
+ String soapActionString = getSOAPAction(msgCtx);
+ String charSetEnc =
+ (String) msgCtx.getProperty(MessageContext.CHARACTER_SET_ENCODING);
+
+ if (charSetEnc != null) {
+ format.setCharSetEncoding(charSetEnc);
+ } else {
+ OperationContext opctx = msgCtx.getOperationContext();
+
+ if (opctx != null) {
+ charSetEnc = (String) opctx.getProperty(MessageContext.CHARACTER_SET_ENCODING);
+ }
+ }
+
+ /**
+ * If the char set enc is still not found use the default
+ */
+ if (charSetEnc == null) {
+ charSetEnc = MessageContext.DEFAULT_CHAR_SET_ENCODING;
+ }
+
+ format.setSOAP11(msgCtx.isSOAP11());
+ format.setCharSetEncoding(charSetEnc);
+
+ String encoding = format.getCharSetEncoding();
+ String contentType = format.getContentType();
+
+ if (encoding != null) {
+ contentType += "; charset=" + encoding;
+ }
+
+ // action header is not mandated in SOAP 1.2. So putting it, if available
+ if (!msgCtx.isSOAP11() && (soapActionString != null)
+ && !"".equals(soapActionString.trim())) {
+ contentType = contentType + ";action=\"" + soapActionString + "\";";
+ }
+
+ return contentType;
+ }
+
+ private String getSOAPAction(MessageContext msgCtx) {
+ String soapActionString = msgCtx.getSoapAction();
+
+ if ((soapActionString == null) || (soapActionString.length() == 0)) {
+ soapActionString = msgCtx.getWSAAction();
+ }
+
+ if (soapActionString == null) {
+ soapActionString = "";
+ }
+
+ return soapActionString;
+ }
+}
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/SimpleJMSListener.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/SimpleJMSListener.java?rev=395668&r1=395667&r2=395668&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/SimpleJMSListener.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/SimpleJMSListener.java Thu Apr 20 11:31:02 2006
@@ -76,7 +76,7 @@
File repo = new File(repositoryDirectory);
if (repo.exists()) {
this.configurationContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(
- repositoryDirectory, null);
+ repositoryDirectory, repositoryDirectory + "/conf/axis2.xml");
} else {
throw new Exception("repository not found");
}
Modified: webservices/axis2/trunk/java/modules/integration/maven.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/maven.xml?rev=395668&r1=395667&r2=395668&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/maven.xml (original)
+++ webservices/axis2/trunk/java/modules/integration/maven.xml Thu Apr 20 11:31:02 2006
@@ -215,6 +215,24 @@
<copy file="test/org/apache/axis2/engine/chunking-disabled-axis2.xml"
tofile="target/test-resources/chunking-disabledRepository/conf/axis2.xml"/>
+ <!-- Create JMS enabled Server Repository -->
+ <mkdir dir="target/test-resources/jms-enabled-server-repository"/>
+ <mkdir dir="target/test-resources/jms-enabled-server-repository/conf"/>
+ <mkdir dir="target/test-resources/jms-enabled-server-repository/modules"/>
+ <copy file="test/org/apache/axis2/jms/jms-enabled-server-axis2.xml"
+ tofile="target/test-resources/jms-enabled-server-repository/conf/axis2.xml"/>
+ <copy file="../addressing/target/addressing-${addressing_version}.mar"
+ tofile="target/test-resources/jms-enabled-server-repository/modules/addressing-${addressing_version}.mar"/>
+
+ <!-- Create JMS enabled Client Repository -->
+ <mkdir dir="target/test-resources/jms-enabled-client-repository"/>
+ <mkdir dir="target/test-resources/jms-enabled-client-repository/conf"/>
+ <mkdir dir="target/test-resources/jms-enabled-client-repository/modules"/>
+ <copy file="test/org/apache/axis2/jms/jms-enabled-client-axis2.xml"
+ tofile="target/test-resources/jms-enabled-client-repository/conf/axis2.xml"/>
+ <copy file="../addressing/target/addressing-${addressing_version}.mar"
+ tofile="target/test-resources/jms-enabled-client-repository/modules/addressing-${addressing_version}.mar"/>
+
<!-- Create Mail Client transport enabled Repository -->
<mkdir dir="target/test-resources/mail-transport-client-enabledRepository"/>
<mkdir dir="target/test-resources/mail-transport-client-enabledRepository/conf"/>
Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/integration/UtilServer.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/integration/UtilServer.java?rev=395668&r1=395667&r2=395668&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/integration/UtilServer.java (original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/integration/UtilServer.java Thu Apr 20 11:31:02 2006
@@ -209,6 +209,13 @@
return configContext;
}
+ public static ConfigurationContext createClientConfigurationContext(String repo) throws AxisFault {
+ ConfigurationContext configContext = ConfigurationContextFactory .createConfigurationContextFromFileSystem(
+ repo,
+ repo + "/conf/axis2.xml");
+ return configContext;
+ }
+
public static ServiceContext createAdressedEnabledClientSide(
AxisService service, String clientHome) throws AxisFault {
DeploymentEngine deploymentEngine = new DeploymentEngine();
Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/integration/UtilsJMSServer.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/integration/UtilsJMSServer.java?rev=395668&r1=395667&r2=395668&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/integration/UtilsJMSServer.java (original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/integration/UtilsJMSServer.java Thu Apr 20 11:31:02 2006
@@ -40,6 +40,8 @@
public static final String FAILURE_MESSAGE = "Intentional Failure";
+ public static final String REPOSITORY_JMS = "target/test-resources/jms-enabled-server-repository";
+
private static Log log = LogFactory.getLog(UtilsJMSServer.class);
public static synchronized void deployService(AxisService service)
@@ -72,22 +74,21 @@
cfMap.put(JNDIVendorAdapter.PROVIDER_URL, "tcp://localhost:61616");
// start JMS server
- File file = new File(org.apache.axis2.Constants.TESTING_REPOSITORY);
+ File file = new File(REPOSITORY_JMS);
System.out.println(file.getAbsoluteFile());
if (!file.exists()) {
throw new Exception("Repository directory does not exist");
}
ConfigurationContext er = ConfigurationContextFactory.createConfigurationContextFromFileSystem(file
- .getAbsolutePath(),null);
+ .getAbsolutePath(),REPOSITORY_JMS + "/conf/axis2.xml");
try {
Thread.sleep(2000);
} catch (InterruptedException e1) {
throw new AxisFault("Thread interuptted", e1);
}
- er.getAxisConfiguration().engageModule(new QName("addressing"));
receiver = new SimpleJMSListener(
- org.apache.axis2.Constants.TESTING_REPOSITORY,
+ REPOSITORY_JMS,
connectorMap, cfMap, destination, username, password,
doThreads);
receiver.start();
Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/jms/JMSEchoRawXMLTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/jms/JMSEchoRawXMLTest.java?rev=395668&r1=395667&r2=395668&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/jms/JMSEchoRawXMLTest.java (original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/jms/JMSEchoRawXMLTest.java Thu Apr 20 11:31:02 2006
@@ -1,237 +1,240 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.axis2.jms;
-
-
-import junit.framework.TestCase;
-import org.apache.axiom.om.OMAbstractFactory;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMFactory;
-import org.apache.axiom.om.OMNamespace;
-import org.apache.axiom.soap.SOAPFactory;
-import org.apache.axiom.soap.SOAPEnvelope;
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.Constants;
-import org.apache.axis2.wsdl.WSDLConstants;
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.client.Options;
-import org.apache.axis2.client.ServiceClient;
-import org.apache.axis2.client.OperationClient;
-import org.apache.axis2.client.async.AsyncResult;
-import org.apache.axis2.client.async.Callback;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.ConfigurationContextFactory;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.description.AxisOperation;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.description.OutInAxisOperation;
-import org.apache.axis2.engine.AxisConfiguration;
-import org.apache.axis2.engine.Echo;
-import org.apache.axis2.integration.UtilServer;
-import org.apache.axis2.integration.UtilsJMSServer;
-import org.apache.axis2.util.Utils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamException;
-
-public class JMSEchoRawXMLTest extends TestCase {
- private EndpointReference targetEPR =
- new EndpointReference("jms:/dynamicQueues/BAR?ConnectionFactoryJNDIName=ConnectionFactory&java.naming.factory.initial=org.activemq.jndi.ActiveMQInitialContextFactory&java.naming.provider.url=tcp://localhost:61616");
- private QName serviceName = new QName("EchoXMLService");
- private QName operationName = new QName("echoOMElement");
-
- private AxisService service;
- private AxisService clientService;
- private ConfigurationContext configContext;
-
- private boolean finish = false;
- private Log log = LogFactory.getLog(getClass());
-
- public JMSEchoRawXMLTest() {
- super(JMSEchoRawXMLTest.class.getName());
- }
-
- public JMSEchoRawXMLTest(String testName) {
- super(testName);
- }
-
- protected void setUp() throws Exception {
- UtilsJMSServer.start();
-
- //create and deploy the service
- service =
- Utils.createSimpleService(serviceName,
- Echo.class.getName(),
- operationName);
- UtilsJMSServer.deployService(service);
- clientService = Utils.createSimpleServiceforClient(serviceName,
- Echo.class.getName(),
- operationName);
- configContext = UtilServer.createClientConfigurationContext();
- }
-
- protected void tearDown() throws Exception {
- UtilsJMSServer.stop();
- }
-
- private OMElement createPayload() {
- OMFactory fac = OMAbstractFactory.getOMFactory();
- OMNamespace omNs = fac.createOMNamespace("http://localhost/axis2/services/EchoXMLService", "my");
- OMElement method = fac.createOMElement("echoOMElement", omNs);
- OMElement value = fac.createOMElement("myValue", omNs);
- value.addChild(
- fac.createOMText(value, "Isaac Asimov, The Foundation Trilogy"));
- method.addChild(value);
-
- return method;
- }
-
- public void testEchoXMLASync() throws Exception {
- OMElement payload = createPayload();
- Options options = new Options();
- options.setTo(targetEPR);
- options.setTransportInProtocol(Constants.TRANSPORT_JMS);
- options.setAction(serviceName.getLocalPart());
-
- Callback callback = new Callback() {
- public void onComplete(AsyncResult result) {
- try {
- result.getResponseEnvelope().serialize(XMLOutputFactory.newInstance()
- .createXMLStreamWriter(System.out));
- } catch (XMLStreamException e) {
- onError(e);
- } finally {
- finish = true;
- }
- }
-
- public void onError(Exception e) {
- log.info(e.getMessage());
- finish = true;
- }
- };
-
- ServiceClient sender = new ServiceClient(configContext, clientService);
- sender.setOptions(options);
- sender.sendReceiveNonBlocking(operationName, payload, callback);
-
-
- int index = 0;
- while (!finish) {
- Thread.sleep(10000);
- index++;
- if (index > 10) {
- throw new AxisFault(
- "Server was shutdown as the async response take too long to complete");
- }
- }
- }
-
- public void testEchoXMLSync() throws Exception {
- OMElement payload = createPayload();
- Options options = new Options();
- options.setTo(targetEPR);
- options.setTransportInProtocol(Constants.TRANSPORT_JMS);
- options.setAction(serviceName.getLocalPart());
- ServiceClient sender = new ServiceClient(configContext, clientService);
- sender.setOptions(options);
-
- OMElement result = sender.sendReceive(operationName, payload);
-
-
- result.serialize(XMLOutputFactory.newInstance().createXMLStreamWriter(
- System.out));
-
- }
-
- public void testEchoXMLCompleteSync() throws Exception {
-
- OMFactory fac = OMAbstractFactory.getOMFactory();
-
- OMNamespace omNs = fac.createOMNamespace("http://localhost/axis2/services/EchoXMLService", "my");
- OMElement payloadElement = fac.createOMElement("echoOMElement", omNs);
- OMElement value = fac.createOMElement("myValue", omNs);
- value.setText("Isaac Asimov, The Foundation Trilogy");
- payloadElement.addChild(value);
-
- Options options = new Options();
- options.setTo(targetEPR);
- options.setAction(operationName.getLocalPart());
- options.setTransportInProtocol(Constants.TRANSPORT_JMS);
- options.setUseSeparateListener(true);
-
- ServiceClient sender = new ServiceClient(configContext, clientService);
- sender.setOptions(options);
-
- OMElement result = sender.sendReceive(operationName, payloadElement);
-
- result.serialize(XMLOutputFactory.newInstance().createXMLStreamWriter(
- System.out));
-
- }
-
- public void testEchoXMLSyncMC() throws Exception {
- ConfigurationContext configContext =
- ConfigurationContextFactory.createConfigurationContextFromFileSystem(Constants.TESTING_REPOSITORY, Constants.TESTING_REPOSITORY + "/conf/axis2.xml");
-
- AxisOperation opdesc = new OutInAxisOperation(new QName("echoOMElement"));
- Options options = new Options();
- options.setTo(targetEPR);
- options.setAction(operationName.getLocalPart());
- options.setTransportInProtocol(Constants.TRANSPORT_JMS);
-
- OMFactory fac = OMAbstractFactory.getOMFactory();
-
- OMNamespace omNs = fac.createOMNamespace("http://localhost/axis2/services/EchoXMLService", "my");
- OMElement method = fac.createOMElement("echoOMElement", omNs);
- OMElement value = fac.createOMElement("myValue", omNs);
- value.setText("Isaac Asimov, The Foundation Trilogy");
- method.addChild(value);
- SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
- SOAPEnvelope envelope = factory.getDefaultEnvelope();
- envelope.getBody().addChild(method);
-
- MessageContext requestContext = new MessageContext();
- requestContext.setConfigurationContext(configContext);
- requestContext.setAxisService(clientService);
- requestContext.setAxisOperation(opdesc);
- requestContext.setEnvelope(envelope);
-
- ServiceClient sender = new ServiceClient(configContext, clientService);
- sender.setOptions(options);
- OperationClient opClient = sender.createClient(new QName("echoOMElement"));
- opClient.addMessageContext(requestContext);
- opClient.setOptions(options);
- opClient.execute(true);
-
- MessageContext response = opClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
- SOAPEnvelope env = response.getEnvelope();
- assertNotNull(env);
- env.getBody().serialize(XMLOutputFactory.newInstance().createXMLStreamWriter(
- System.out));
- sender.finalizeInvoke();
- }
-}
-
-
-
-
-
-
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.axis2.jms;
+
+
+import junit.framework.TestCase;
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.wsdl.WSDLConstants;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.client.OperationClient;
+import org.apache.axis2.client.async.AsyncResult;
+import org.apache.axis2.client.async.Callback;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.OutInAxisOperation;
+import org.apache.axis2.description.TransportOutDescription;
+import org.apache.axis2.description.TransportInDescription;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.engine.Echo;
+import org.apache.axis2.integration.UtilServer;
+import org.apache.axis2.integration.UtilsJMSServer;
+import org.apache.axis2.util.Utils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+
+public class JMSEchoRawXMLTest extends TestCase {
+ private EndpointReference targetEPR =
+ new EndpointReference("jms:/dynamicQueues/BAR?ConnectionFactoryJNDIName=ConnectionFactory&java.naming.factory.initial=org.activemq.jndi.ActiveMQInitialContextFactory&java.naming.provider.url=tcp://localhost:61616");
+ private QName serviceName = new QName("EchoXMLService");
+ private QName operationName = new QName("echoOMElement");
+
+ private AxisService service;
+ private AxisService clientService;
+ private ConfigurationContext configContext;
+
+ private boolean finish = false;
+ private Log log = LogFactory.getLog(getClass());
+
+ public JMSEchoRawXMLTest() {
+ super(JMSEchoRawXMLTest.class.getName());
+ }
+
+ public JMSEchoRawXMLTest(String testName) {
+ super(testName);
+ }
+
+ protected void setUp() throws Exception {
+ UtilsJMSServer.start();
+
+ //create and deploy the service
+ service =
+ Utils.createSimpleService(serviceName,
+ Echo.class.getName(),
+ operationName);
+ UtilsJMSServer.deployService(service);
+ clientService = Utils.createSimpleServiceforClient(serviceName,
+ Echo.class.getName(),
+ operationName);
+ configContext = UtilServer.createClientConfigurationContext();
+ }
+
+ protected void tearDown() throws Exception {
+ UtilsJMSServer.stop();
+ }
+
+ private OMElement createPayload() {
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMNamespace omNs = fac.createOMNamespace("http://localhost/axis2/services/EchoXMLService", "my");
+ OMElement method = fac.createOMElement("echoOMElement", omNs);
+ OMElement value = fac.createOMElement("myValue", omNs);
+ value.addChild(
+ fac.createOMText(value, "Isaac Asimov, The Foundation Trilogy"));
+ method.addChild(value);
+
+ return method;
+ }
+
+ public void testEchoXMLASync() throws Exception {
+ OMElement payload = createPayload();
+ Options options = new Options();
+ options.setTo(targetEPR);
+ options.setTransportInProtocol(Constants.TRANSPORT_JMS);
+ options.setAction(serviceName.getLocalPart());
+
+ Callback callback = new Callback() {
+ public void onComplete(AsyncResult result) {
+ try {
+ result.getResponseEnvelope().serialize(XMLOutputFactory.newInstance()
+ .createXMLStreamWriter(System.out));
+ } catch (XMLStreamException e) {
+ onError(e);
+ } finally {
+ finish = true;
+ }
+ }
+
+ public void onError(Exception e) {
+ log.info(e.getMessage());
+ finish = true;
+ }
+ };
+
+ ServiceClient sender = new ServiceClient(configContext, clientService);
+ sender.setOptions(options);
+ sender.sendReceiveNonBlocking(operationName, payload, callback);
+
+
+ int index = 0;
+ while (!finish) {
+ Thread.sleep(10000);
+ index++;
+ if (index > 10) {
+ throw new AxisFault(
+ "Server was shutdown as the async response take too long to complete");
+ }
+ }
+ }
+
+ public void testEchoXMLSync() throws Exception {
+ OMElement payload = createPayload();
+ Options options = new Options();
+ options.setTo(targetEPR);
+ options.setTransportInProtocol(Constants.TRANSPORT_JMS);
+ options.setAction(serviceName.getLocalPart());
+ ServiceClient sender = new ServiceClient(configContext, clientService);
+ sender.setOptions(options);
+
+ OMElement result = sender.sendReceive(operationName, payload);
+
+
+ result.serialize(XMLOutputFactory.newInstance().createXMLStreamWriter(
+ System.out));
+
+ }
+
+ public void testEchoXMLCompleteSync() throws Exception {
+ ConfigurationContext configContext = UtilServer.createClientConfigurationContext("target/test-resources/jms-enabled-client-repository");
+
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+
+ OMNamespace omNs = fac.createOMNamespace("http://localhost/axis2/services/EchoXMLService", "my");
+ OMElement payloadElement = fac.createOMElement("echoOMElement", omNs);
+ OMElement value = fac.createOMElement("myValue", omNs);
+ value.setText("Isaac Asimov, The Foundation Trilogy");
+ payloadElement.addChild(value);
+
+ Options options = new Options();
+ options.setTo(targetEPR);
+ options.setAction(Constants.AXIS2_NAMESPACE_URI+"/"+operationName.getLocalPart());
+ options.setTransportInProtocol(Constants.TRANSPORT_JMS);
+ options.setUseSeparateListener(true);
+ options.setTimeOutInMilliSeconds(60*60*1000);
+
+ ServiceClient sender = new ServiceClient(configContext, clientService);
+ sender.setOptions(options);
+ OMElement result = sender.sendReceive(operationName, payloadElement);
+
+ result.serialize(XMLOutputFactory.newInstance().createXMLStreamWriter(
+ System.out));
+
+ }
+
+ public void testEchoXMLSyncMC() throws Exception {
+ ConfigurationContext configContext =
+ ConfigurationContextFactory.createConfigurationContextFromFileSystem(Constants.TESTING_REPOSITORY, Constants.TESTING_REPOSITORY + "/conf/axis2.xml");
+
+ AxisOperation opdesc = new OutInAxisOperation(new QName("echoOMElement"));
+ Options options = new Options();
+ options.setTo(targetEPR);
+ options.setAction(operationName.getLocalPart());
+ options.setTransportInProtocol(Constants.TRANSPORT_JMS);
+
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+
+ OMNamespace omNs = fac.createOMNamespace("http://localhost/axis2/services/EchoXMLService", "my");
+ OMElement method = fac.createOMElement("echoOMElement", omNs);
+ OMElement value = fac.createOMElement("myValue", omNs);
+ value.setText("Isaac Asimov, The Foundation Trilogy");
+ method.addChild(value);
+ SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
+ SOAPEnvelope envelope = factory.getDefaultEnvelope();
+ envelope.getBody().addChild(method);
+
+ MessageContext requestContext = new MessageContext();
+ requestContext.setConfigurationContext(configContext);
+ requestContext.setAxisService(clientService);
+ requestContext.setAxisOperation(opdesc);
+ requestContext.setEnvelope(envelope);
+
+ ServiceClient sender = new ServiceClient(configContext, clientService);
+ sender.setOptions(options);
+ OperationClient opClient = sender.createClient(new QName("echoOMElement"));
+ opClient.addMessageContext(requestContext);
+ opClient.setOptions(options);
+ opClient.execute(true);
+
+ MessageContext response = opClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+ SOAPEnvelope env = response.getEnvelope();
+ assertNotNull(env);
+ env.getBody().serialize(XMLOutputFactory.newInstance().createXMLStreamWriter(
+ System.out));
+ sender.finalizeInvoke();
+ }
+}
+
+
+
+
+
+
Added: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/jms/jms-enabled-client-axis2.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/jms/jms-enabled-client-axis2.xml?rev=395668&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/jms/jms-enabled-client-axis2.xml (added)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/jms/jms-enabled-client-axis2.xml Thu Apr 20 11:31:02 2006
@@ -0,0 +1,192 @@
+<axisconfig name="AxisJava2.0">
+ <!-- ================================================= -->
+ <!-- Parameters -->
+ <!-- ================================================= -->
+ <parameter name="hotdeployment" locked="false">true</parameter>
+ <parameter name="hotupdate" locked="false">false</parameter>
+ <parameter name="enableMTOM" locked="false">false</parameter>
+ <parameter name="sendStacktraceDetailsWithFaults" locked="false">true</parameter>
+
+ <!-- Uncomment this to enable REST support -->
+ <!-- <parameter name="enableREST" locked="false">true</parameter>-->
+
+
+ <parameter name="userName" locked="false">admin</parameter>
+ <parameter name="password" locked="false">axis2</parameter>
+
+ <!-- The way of adding listener to the system-->
+ <!-- <listener class="org.apache.axis2.ObserverIMPL">-->
+ <!-- <parameter name="RSS_URL" locked="false">http://127.0.0.1/rss</parameter>-->
+ <!-- </listener>-->
+
+ <!-- ================================================= -->
+ <!-- Message Receivers -->
+ <!-- ================================================= -->
+ <!--This is the Deafult Message Receiver for the system , if you want to have MessageReceivers for -->
+ <!--all the other MEP implement it and add the correct entry to here , so that you can refer from-->
+ <!--any operation -->
+ <!--Note : You can ovride this for particular service by adding the same element with your requirement-->
+ <messageReceivers>
+ <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only"
+ class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/>
+ <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
+ class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
+ </messageReceivers>
+ <!-- ================================================= -->
+ <!-- Transport Ins -->
+ <!-- ================================================= -->
+ <transportReceiver name="http"
+ class="org.apache.axis2.transport.http.SimpleHTTPServer">
+ <parameter name="port" locked="false">6060</parameter>
+ <!--If you want to give your own host address for EPR generation-->
+ <!--uncommet following paramter , and set as you required.-->
+ <!--<parameter name="hostname" locked="false">http://myApp.com/ws</parameter>-->
+ </transportReceiver>
+
+ <!--Uncomment if you want to have SMTP transport support-->
+ <!--<transportReceiver name="mail" class="org.apache.axis2.transport.mail.SimpleMailListener">-->
+ <!--<parameter name="transport.mail.pop3.host" locked="false">127.0.0.1</parameter>-->
+ <!--<parameter name="transport.mail.pop3.user" locked="false">axis2</parameter>-->
+ <!--<parameter name="transport.mail.pop3.password" locked="false">axis2</parameter>-->
+ <!--<parameter name="transport.mail.pop3.port" locked="false">110</parameter>-->
+ <!--<parameter name="transport.mail.replyToAddress" locked="false">axis2@127.0.0.1</parameter>-->
+ <!--</transportReceiver>-->
+
+ <transportReceiver name="tcp"
+ class="org.apache.axis2.transport.tcp.TCPServer">
+ <parameter name="port" locked="false">6060</parameter>
+ <!--If you want to give your own host address for EPR generation-->
+ <!--uncommet following paramter , and set as you required.-->
+ <!--<parameter name="hostname" locked="false">tcp://myApp.com/ws</parameter>-->
+ </transportReceiver>
+
+ <!--Uncomment this if you want JMS transport support-->
+ <transportReceiver name="jms" class="org.apache.axis2.transport.jms.SimpleJMSListener">
+ <parameter name="transport.jms.Destination" locked="false">dynamicQueues/FOO</parameter>
+ <parameter name="java.naming.factory.initial" locked="false">org.activemq.jndi.ActiveMQInitialContextFactory</parameter>
+ <parameter name="java.naming.provider.url" locked="false">tcp://localhost:61616</parameter>
+ </transportReceiver>
+
+ <!-- ================================================= -->
+ <!-- Transport Outs -->
+ <!-- ================================================= -->
+
+ <transportSender name="tcp"
+ class="org.apache.axis2.transport.tcp.TCPTransportSender"/>
+ <transportSender name="local"
+ class="org.apache.axis2.transport.local.LocalTransportSender"/>
+ <transportSender name="jms"
+ class="org.apache.axis2.transport.jms.JMSSender"/>
+ <transportSender name="http"
+ class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
+ <parameter name="PROTOCOL" locked="false">HTTP/1.1</parameter>
+ <parameter name="Transfer-Encoding" locked="false">chunked</parameter>
+ </transportSender>
+ <transportSender name="https"
+ class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
+ <parameter name="PROTOCOL" locked="false">HTTP/1.1</parameter>
+ <parameter name="Transfer-Encoding" locked="false">chunked</parameter>
+ </transportSender>
+
+ <!-- Uncomment this one with the appropriate papameters to enable the SMTP transport Receiver
+ <transportSender name="mailto" class="org.apache.axis2.transport.mail.MailTransportSender">
+ <parameter name="transport.mail.smtp.host" locked="false">127.0.0.1</parameter>
+ <parameter name="transport.mail.smtp.user" locked="false">axis2</parameter>
+ <parameter name="transport.mail.smtp.password" locked="false">axis2</parameter>
+ <parameter name="transport.mail.smtp.port" locked="false">25</parameter>
+ </transportSender>
+ -->
+
+ <!-- ================================================= -->
+ <!-- Global Modules -->
+ <!-- ================================================= -->
+ <!-- Comment this to disable Addressing -->
+ <module ref="addressing"/>
+
+ <!--Configuring module , providing parameters for modules whether they refer or not-->
+ <!--<moduleConfig name="addressing">-->
+ <!--<parameter name="addressingPara" locked="false">N/A</parameter>-->
+ <!--</moduleConfig>-->
+
+ <!-- ================================================= -->
+ <!-- Phases -->
+ <!-- ================================================= -->
+ <phaseOrder type="inflow">
+ <!-- System pre defined phases -->
+ <phase name="Transport">
+ <handler name="RequestURIBasedDispatcher"
+ class="org.apache.axis2.engine.RequestURIBasedDispatcher">
+ <order phase="Dispatch"/>
+ </handler>
+ <handler name="SOAPActionBasedDispatcher"
+ class="org.apache.axis2.engine.SOAPActionBasedDispatcher">
+ <order phase="Dispatch"/>
+ </handler>
+ </phase>
+ <phase name="Security"/>
+ <phase name="PreDispatch"/>
+ <phase name="Dispatch" class="org.apache.axis2.engine.DispatchPhase">
+ <handler name="AddressingBasedDispatcher"
+ class="org.apache.axis2.engine.AddressingBasedDispatcher">
+ <order phase="Dispatch"/>
+ </handler>
+
+ <handler name="SOAPMessageBodyBasedDispatcher"
+ class="org.apache.axis2.engine.SOAPMessageBodyBasedDispatcher">
+ <order phase="Dispatch"/>
+ </handler>
+ <handler name="InstanceDispatcher"
+ class="org.apache.axis2.engine.InstanceDispatcher">
+ <order phase="PostDispatch"/>
+ </handler>
+ </phase>
+ <!-- System pre defined phases -->
+ <!-- After Postdispatch phase module author or or service author can add any phase he want -->
+ <phase name="OperationInPhase"/>
+ </phaseOrder>
+ <phaseOrder type="outflow">
+ <!-- user can add his own phases to this area -->
+ <phase name="OperationOutPhase"/>
+ <!--system predefined phase-->
+ <!--these phase will run irrespective of the service-->
+ <phase name="PolicyDetermination"/>
+ <phase name="MessageOut"/>
+ </phaseOrder>
+ <phaseOrder type="INfaultflow">
+ <phase name="PreDispatch"/>
+ <phase name="Dispatch" class="org.apache.axis2.engine.DispatchPhase">
+ <handler name="RequestURIBasedDispatcher"
+ class="org.apache.axis2.engine.RequestURIBasedDispatcher">
+ <order phase="Dispatch"/>
+ </handler>
+
+ <handler name="SOAPActionBasedDispatcher"
+ class="org.apache.axis2.engine.SOAPActionBasedDispatcher">
+ <order phase="Dispatch"/>
+ </handler>
+
+ <handler name="AddressingBasedDispatcher"
+ class="org.apache.axis2.engine.AddressingBasedDispatcher">
+ <order phase="Dispatch"/>
+ </handler>
+
+ <handler name="SOAPMessageBodyBasedDispatcher"
+ class="org.apache.axis2.engine.SOAPMessageBodyBasedDispatcher">
+ <order phase="Dispatch"/>
+ </handler>
+ <handler name="InstanceDispatcher"
+ class="org.apache.axis2.engine.InstanceDispatcher">
+ <order phase="PostDispatch"/>
+ </handler>
+ </phase>
+ <!-- user can add his own phases to this area -->
+ <phase name="OperationInFaultPhase"/>
+ </phaseOrder>
+ <phaseOrder type="Outfaultflow">
+ <!-- user can add his own phases to this area -->
+ <phase name="OperationOutFaultPhase"/>
+ <phase name="PolicyDetermination"/>
+ <phase name="MessageOut"/>
+ </phaseOrder>
+</axisconfig>
+