You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by de...@apache.org on 2005/12/29 11:43:26 UTC
svn commit: r359771 [1/2] - in /webservices/axis2/trunk/java/modules:
core/src/org/apache/axis2/client/ core/src/org/apache/axis2/context/
core/src/org/apache/axis2/description/ core/src/org/apache/axis2/util/
integration/test/org/apache/axis2/engine/ ...
Author: deepal
Date: Thu Dec 29 02:42:30 2005
New Revision: 359771
URL: http://svn.apache.org/viewcvs?rev=359771&view=rev
Log:
Intregarte ServiceClient to integration test cases ,
now Serviceclient is capable of handling all the following scenarios
1.Fireandforget
2.sendRecive (block and non-blocking)
3.sendRecieveNonBlocking
And now we can get rid from InOutMepClient , InOnlyMepClient and MessageSender
Modified:
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/InOutMEPClient.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/Options.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/ServiceClient.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ConfigurationContext.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/ClientUtils.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/OutInAxisOperation.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/Utils.java
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/CallUnregisteredServiceTest.java
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/CharactersetEncodingTest.java
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/CommonsHTTPEchoRawXMLTest.java
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/EchoRawRuntimeProxyTest.java
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/EchoRawXMLChunkedTest.java
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/EchoRawXMLLoadTest.java
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/EchoRawXMLMultipleTest.java
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/EchoRawXMLOnTwoChannelsSyncTest.java
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/EchoRawXMLOnTwoChannelsTest.java
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/EchoRawXMLTest.java
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/FaultHandlingTest.java
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/HandlerFailureTest.java
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/MessageContextInjectionTest.java
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/MessageWithServerTest.java
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/OneWayRawXMLTest.java
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/SOAPversionTest.java
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/ServiceDispatchingTest.java
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/ServiceGroupContextTest.java
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/groovy/GroovyServiceTest.java
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/integration/EchoTest.java
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/jms/JMSEchoRawXMLTest.java
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMCommonsChunkingTest.java
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMFileCacheLoadTest.java
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMFileCacheTest.java
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMLoadTest.java
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMTest.java
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMToBase64Test.java
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/tcp/TCPEchoRawXMLTest.java
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/tcp/TCPTwoChannelEchoRawXMLTest.java
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/InOutMEPClient.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/InOutMEPClient.java?rev=359771&r1=359770&r2=359771&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/InOutMEPClient.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/InOutMEPClient.java Thu Dec 29 02:42:30 2005
@@ -120,8 +120,6 @@
ListenerManager.stop(serviceContext.getConfigurationContext(),
clientOptions.getTransportInDescription().getName().getLocalPart());
}
-
-
}
protected void configureTransportInformation(MessageContext msgCtx) throws AxisFault {
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/Options.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/Options.java?rev=359771&r1=359770&r2=359771&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/Options.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/Options.java Thu Dec 29 02:42:30 2005
@@ -4,6 +4,7 @@
import org.apache.axis2.Constants;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.addressing.RelatesTo;
+import org.apache.axis2.client.async.Callback;
import org.apache.axis2.description.TransportInDescription;
import org.apache.axis2.description.TransportOutDescription;
import org.apache.axis2.engine.AxisConfiguration;
@@ -73,6 +74,8 @@
protected TransportOutDescription senderTransport;
private String senderTransportProtocol;
private EndpointReference to;
+ // TODO : This is a hack to solve the problem of passsing CallBack object into OperationClient
+ private Callback callback;
/**
* Default constructor
@@ -436,5 +439,15 @@
}
referenceParameters.add(referenceParameter);
+ }
+
+ public Callback getCallback() {
+ //todo : pls remove this
+ return callback;
+ }
+
+ public void setCallback(Callback callback) {
+ //todo : pls remove this
+ this.callback = callback;
}
}
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/ServiceClient.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/ServiceClient.java?rev=359771&r1=359770&r2=359771&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/ServiceClient.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/ServiceClient.java Thu Dec 29 02:42:30 2005
@@ -1,16 +1,23 @@
package org.apache.axis2.client;
import org.apache.axis2.AxisFault;
+import org.apache.axis2.client.async.AsyncResult;
import org.apache.axis2.client.async.Callback;
import org.apache.axis2.context.*;
import org.apache.axis2.description.*;
import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.i18n.Messages;
import org.apache.axis2.om.OMAbstractFactory;
import org.apache.axis2.om.OMElement;
import org.apache.axis2.soap.SOAP12Constants;
import org.apache.axis2.soap.SOAPEnvelope;
import org.apache.axis2.soap.SOAPFactory;
import org.apache.axis2.soap.SOAPHeader;
+import org.apache.axis2.util.CallbackReceiver;
+import org.apache.axis2.util.UUIDGenerator;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.wsdl.WSDLConstants;
import javax.xml.namespace.QName;
import java.net.URL;
@@ -21,6 +28,9 @@
* need to be explained here.
*/
public class ServiceClient {
+
+ private Log log = LogFactory.getLog(getClass());
+
// service and operation names used for anonymously stuff
private static final String ANON_SERVICE = "__ANONYMOUS_SERVICE__";
@@ -47,6 +57,12 @@
// list of headers to be sent with the simple APIs
ArrayList headers;
+ //to set the name of the operation to be invoked , and this is usefull if the user
+ // try to reuse same ServiceClent to invoke more than one operation in the service ,
+ // in that case he can set the current operation name and invoke that.
+ private QName currentOperationName = null;
+
+ private CallbackReceiver callbackReceiver;
/**
* Create a service client configured to work with a specific AxisService.
@@ -92,7 +108,13 @@
* necessary information.
*/
public ServiceClient() throws AxisFault {
- this(null);
+ this((ConfigurationContext) null);
+ }
+
+ public ServiceClient(ServiceContext serviceContext) {
+ this.serviceContext = serviceContext;
+ this.configContext = serviceContext.getConfigurationContext();
+ this.axisService = serviceContext.getAxisService();
}
/**
@@ -225,18 +247,7 @@
if (serviceContext == null) {
createServiceContext();
}
- mc.setServiceContext(serviceContext);
- SOAPFactory sf = getSOAPFactory();
- SOAPEnvelope se = sf.getDefaultEnvelope();
- se.getBody().addChild(elem);
- if (headers != null) {
- SOAPHeader sh = se.getHeader();
- for (int i = 0; i < headers.size(); i++) {
- OMElement headerBlock = (OMElement) headers.get(i);
- sh.addChild(headerBlock);
- }
- }
- mc.setEnvelope(se);
+ fillSoapEnevelop(mc, elem);
// look up the appropriate axisop and create the client
OperationClient mepClient = getAxisService().getOperation(ANON_OUT_ONLY_OP)
@@ -251,24 +262,140 @@
if (serviceContext == null) {
createServiceContext();
}
- // look up the appropriate axisop and create the client
- OperationClient mepClient = getAxisService().getOperation(ANON_OUT_IN_OP)
- .createClient(serviceContext, options);
- // TODO
- throw new UnsupportedOperationException(
- "ServiceClient.sendReceive() is not yet implemented");
+ if (options.isUseSeparateListener()) {
+
+ // This mean doing a Request-Response invocation using two channel. If the
+ // transport is two way transport (e.g. http) Only one channel is used (e.g. in http cases
+ // 202 OK is sent to say no repsone avalible). Axis2 get blocked return when the response is avalible.
+ SyncCallBack callback = new SyncCallBack();
+
+ // this method call two channel non blocking method to do the work and wait on the callbck
+ sendReceiveNonblocking(elem, callback);
+
+ long timeout = options.getTimeOutInMilliSeconds();
+
+ if (timeout < 0) {
+ while (!callback.isComplete()) {
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ throw new AxisFault(e);
+ }
+ }
+ } else {
+ long index = timeout / 100;
+
+ while (!callback.isComplete()) {
+
+ // wait till the reponse arrives
+ if (index-- >= 0) {
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ throw new AxisFault(e);
+ }
+ } else {
+ throw new AxisFault(Messages.getMessage("responseTimeOut"));
+ }
+ }
+ }
+ // process the resule of the invocation
+ if (callback.envelope != null) {
+ MessageContext resMsgctx =
+ new MessageContext(serviceContext.getConfigurationContext());
+
+ resMsgctx.setEnvelope(callback.envelope);
+
+ return callback.envelope.getBody().getFirstElement();
+ } else {
+ if (callback.error instanceof AxisFault) {
+ throw(AxisFault) callback.error;
+ } else {
+ throw new AxisFault(callback.error);
+ }
+ }
+ } else {
+ MessageContext mc = new MessageContext();
+ fillSoapEnevelop(mc, elem);
+
+ setMessageID(mc);
+
+ OperationClient mepClient;
+ if (currentOperationName != null) {
+ AxisOperation operation = getAxisService().getOperation(currentOperationName);
+ if (operation == null) {
+ throw new AxisFault("Operation " + currentOperationName + " not find in the given service");
+ }
+ mepClient = operation.createClient(serviceContext, options);
+ } else {
+ // look up the appropriate axisop and create the client
+ mepClient = getAxisService().getOperation(ANON_OUT_IN_OP)
+ .createClient(serviceContext, options);
+ }
+
+ mepClient.setOptions(options);
+ mepClient.addMessageContext(mc);
+
+ mepClient.execute(false);
+ MessageContext response = mepClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+ return response.getEnvelope().getBody().getFirstElement();
+ }
}
public void sendReceiveNonblocking(OMElement elem, Callback callback) throws AxisFault {
if (serviceContext == null) {
createServiceContext();
}
- // look up the appropriate axisop and create the client
- OperationClient mepClient = getAxisService().getOperation(ANON_OUT_IN_OP)
- .createClient(serviceContext, options);
- // TODO
- throw new UnsupportedOperationException(
- "ServiceClient.sendReceiveNonblocking() is not yet implemented");
+ MessageContext mc = new MessageContext();
+ fillSoapEnevelop(mc, elem);
+
+ setMessageID(mc);
+
+ AxisOperation operation;
+ if (currentOperationName != null) {
+ operation = getAxisService().getOperation(currentOperationName);
+ if (operation == null) {
+ throw new AxisFault("Operation " + currentOperationName + " not find in the given service");
+ }
+ } else {
+ // look up the appropriate axisop and create the client
+ operation = getAxisService().getOperation(ANON_OUT_IN_OP);
+ }
+ OperationClient mepClient = operation.createClient(serviceContext, options);
+ // here a bloking invocation happens in a new thread, so the
+ // progamming model is non blocking
+ OperationContext opcontxt = new OperationContext(operation, serviceContext);
+
+ mc.setOperationContext(opcontxt);
+ mc.setServiceContext(serviceContext);
+ opcontxt.setProperties(options.getProperties());
+ options.setCallback(callback);
+ mepClient.addMessageContext(mc);
+ mepClient.setOptions(options);
+ if (options.isUseSeparateListener()) {
+ if (callbackReceiver == null) {
+ callbackReceiver = new CallbackReceiver();
+ }
+ mepClient.setMessageReceiver(callbackReceiver);
+ }
+ mepClient.execute(true);
+ }
+
+ private void fillSoapEnevelop(MessageContext mc, OMElement elem) throws AxisFault {
+ mc.setServiceContext(serviceContext);
+ SOAPFactory sf = getSOAPFactory();
+ SOAPEnvelope se = sf.getDefaultEnvelope();
+ if (elem != null) {
+ se.getBody().addChild(elem);
+ }
+ if (headers != null) {
+ SOAPHeader sh = se.getHeader();
+ for (int i = 0; i < headers.size(); i++) {
+ OMElement headerBlock = (OMElement) headers.get(i);
+ sh.addChild(headerBlock);
+ }
+ }
+ mc.setEnvelope(se);
}
/**
@@ -317,7 +444,7 @@
try {
axisConfig.addService(getAxisService());
} catch (AxisFault axisFault) {
- //todo : need to log this
+ log.info("Error in getAxisService(): " + axisFault.getMessage());
}
}
}
@@ -325,6 +452,69 @@
}
public void setAxisService(AxisService axisService) {
+ // adding service into system
+ AxisConfiguration axisConfig = this.configContext
+ .getAxisConfiguration();
+ if (axisConfig.getService(getAxisService().getName()) == null) {
+ try {
+ axisConfig.addService(getAxisService());
+ } catch (AxisFault axisFault) {
+ log.info("Error in getAxisService(): " + axisFault.getMessage());
+ }
+ }
this.axisService = axisService;
+ }
+
+ private void setMessageID(MessageContext mc) {
+ // now its the time to put the parameters set by the user in to the
+ // correct places and to the
+ // if there is no message id still, set a new one.
+ String messageId = options.getMessageId();
+ if (messageId == null || "".equals(messageId)) {
+ messageId = UUIDGenerator.getUUID();
+ options.setMessageId(messageId);
+ }
+ mc.setMessageID(messageId);
+ }
+
+ /**
+ * To set the opration that need to be invoke , as an example say client creat a
+ * service with mutiple operation and he need to invoke all of them using one service
+ * client in that case he can give the operation name and invoke that operation
+ *
+ * @param currentOperationName
+ */
+ public void setCurrentOperationName(QName currentOperationName) {
+ //todo : pls ask from Sanjiva about this
+ this.currentOperationName = currentOperationName;
+ }
+
+ /**
+ * This will close the out put stream or , and remove entry from waiting queue of the transport
+ * Listener queue
+ *
+ * @throws AxisFault
+ */
+ public void finalizeInvoke() throws AxisFault {
+ if (options.isUseSeparateListener()) {
+ ListenerManager.stop(serviceContext.getConfigurationContext(),
+ options.getTransportInDescription().getName().getLocalPart());
+ }
+ }
+
+ /**
+ * This class acts as a callback that allows users to wait on the result.
+ */
+ private class SyncCallBack extends Callback {
+ private SOAPEnvelope envelope;
+ private Exception error;
+
+ public void onComplete(AsyncResult result) {
+ this.envelope = result.getResponseEnvelope();
+ }
+
+ public void reportError(Exception e) {
+ error = e;
+ }
}
}
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ConfigurationContext.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ConfigurationContext.java?rev=359771&r1=359770&r2=359771&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ConfigurationContext.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ConfigurationContext.java Thu Dec 29 02:42:30 2005
@@ -40,6 +40,7 @@
*/
private final Map operationContextMap = new HashMap();
private Hashtable serviceGroupContextMap = new Hashtable();
+ private Hashtable applicationSessionServiceGroupContextTabale = new Hashtable();
private transient AxisConfiguration axisConfiguration;
private File rootDir;
private transient ThreadFactory threadPool;
@@ -53,7 +54,7 @@
}
protected void finalize() throws Throwable {
- super.finalize();
+ super.finalize();
}
/**
@@ -117,10 +118,8 @@
*/
String maxScope = SessionUtils.calculateMaxScopeForServiceGroup(serviceGroupContext.getDescription());
if (Constants.SCOPE_APPLICATION.equals(maxScope)) {
- //todo : needed to add to two tables
- registerServiceGroupContext(serviceGroupContext);
+ addServiceGroupContextintoApplicatoionScopeTable(serviceGroupContext);
} else if (Constants.SCOPE_SOAP_SESSION.equals(maxScope)) {
- //todo : needed to add to two tables
registerServiceGroupContext(serviceGroupContext);
} else if (Constants.SCOPE_TRANSPORT_SESSION.equals(maxScope)) {
sessionContext.addServiceGroupContext(serviceGroupContext, serviceGroupContextId);
@@ -164,6 +163,11 @@
cleanupServiceGroupContexts();
}
+ private synchronized void addServiceGroupContextintoApplicatoionScopeTable(
+ ServiceGroupContext serviceGroupContext) {
+ applicationSessionServiceGroupContextTabale.put(serviceGroupContext.getId(), serviceGroupContext);
+ }
+
public AxisConfiguration getAxisConfiguration() {
return axisConfiguration;
}
@@ -207,6 +211,10 @@
if (serviceGroupContext == null && msgContext.getSessionContext() != null) {
serviceGroupContext = msgContext.getSessionContext().getServiceGroupContext(
serviceGroupContextId);
+ }
+ if (serviceGroupContext == null) {
+ serviceGroupContext = (ServiceGroupContext)
+ applicationSessionServiceGroupContextTabale.get(serviceGroupContextId);
}
return serviceGroupContext;
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/ClientUtils.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/ClientUtils.java?rev=359771&r1=359770&r2=359771&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/ClientUtils.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/ClientUtils.java Thu Dec 29 02:42:30 2005
@@ -1,22 +1,25 @@
package org.apache.axis2.description;
-import javax.xml.namespace.QName;
-
import org.apache.axis2.AxisFault;
import org.apache.axis2.Constants;
import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.ListenerManager;
import org.apache.axis2.client.Options;
import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.ServiceContext;
import org.apache.axis2.engine.AxisConfiguration;
import org.apache.axis2.i18n.Messages;
+import org.apache.axis2.transport.http.HTTPConstants;
import org.apache.axis2.util.UUIDGenerator;
+import javax.xml.namespace.QName;
+
/**
* Utility methods for various clients to use.
*/
-class ClientUtils {
- static TransportOutDescription inferOutTransport(AxisConfiguration ac,
- EndpointReference epr) throws AxisFault {
+public class ClientUtils {
+ public static TransportOutDescription inferOutTransport(AxisConfiguration ac,
+ EndpointReference epr) throws AxisFault {
if (epr == null || (epr.getAddress() == null)) {
throw new AxisFault(Messages.getMessage("cannotInferTransport"));
}
@@ -31,17 +34,44 @@
}
}
+ public static TransportInDescription inferInTransport(AxisConfiguration ac,
+ Options options,
+ ServiceContext serviceContext) throws AxisFault {
+ String listenerTransportProtocol = options.getTransportInProtocol();
+ TransportInDescription transportIn = null;
+ if (options.isUseSeparateListener()) {
+ if ((listenerTransportProtocol != null) && !"".equals(listenerTransportProtocol)) {
+ transportIn = ac.getTransportIn(new QName(listenerTransportProtocol));
+
+ if (transportIn == null) {
+ throw new AxisFault(Messages.getMessage("unknownTransport",
+ listenerTransportProtocol));
+ }
+ options.setTransportInDescription(transportIn);
+ }
+ // if separate transport is used, start the required listeners
+ if (!ac.isEngaged(new QName(Constants.MODULE_ADDRESSING))) {
+ throw new AxisFault(Messages.getMessage("2channelNeedAddressing"));
+ }
+ ListenerManager.makeSureStarted(options.getTransportInProtocol(),
+ serviceContext.getConfigurationContext());
+ }
+ return transportIn;
+
+ }
+
/**
* Copy data from options to the message context. We really should revisit
* this and push options down into the message context directly.
- *
- * @param options
- * options to copy from
- * @param mc
- * the message context to copy into
+ *
+ * @param options options to copy from
+ * @param mc the message context to copy into
*/
- public static void copyInfoFromOptionsToMessageContext(Options options,
- MessageContext mc) {
+ public static void copyInfoFromOptionsToMessageContext
+ (Options
+ options,
+ MessageContext
+ mc) {
mc.setTo(options.getTo());
mc.setFrom(options.getFrom());
mc.setFaultTo(options.getFaultTo());
@@ -54,6 +84,7 @@
mc.setSoapAction(options.getSoapAction());
mc.setProperty(Constants.Configuration.IS_USING_SEPARATE_LISTENER,
Boolean.valueOf(options.isUseSeparateListener()));
+ mc.setProperty(HTTPConstants.PROXY, options.getProperty(HTTPConstants.PROXY));
}
}
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=359771&r1=359770&r2=359771&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 Dec 29 02:42:30 2005
@@ -1,8 +1,25 @@
package org.apache.axis2.description;
import org.apache.axis2.AxisFault;
+import org.apache.axis2.i18n.Messages;
+import org.apache.axis2.transport.TransportUtils;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.ListenerManager;
+import org.apache.axis2.client.OperationClient;
+import org.apache.axis2.client.Options;
+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.MessageContext;
import org.apache.axis2.context.OperationContext;
+import org.apache.axis2.context.ServiceContext;
+import org.apache.axis2.engine.AxisEngine;
+import org.apache.axis2.engine.MessageReceiver;
+import org.apache.axis2.soap.SOAPBody;
+import org.apache.axis2.soap.SOAPEnvelope;
+import org.apache.axis2.soap.SOAPFault;
+import org.apache.axis2.util.CallbackReceiver;
+import org.apache.wsdl.WSDLConstants;
import javax.xml.namespace.QName;
import java.util.HashMap;
@@ -38,4 +55,335 @@
opContext.setComplete(true);
}
}
+
+ /**
+ * Return a MEP client for an Out-IN operation. This client can be used to
+ * interact with a server which is offering an In-Out operation. To use the
+ * client, you must call addMessageContext() with a message context and then
+ * call execute() to execute the client.
+ *
+ * @param sc The service context for this client to live within. Cannot be
+ * null.
+ * @param options Options to use as defaults for this client. If any options are
+ * set specifically on the client then those override options
+ * here.
+ */
+ public OperationClient createClient(ServiceContext sc, Options options) {
+ return new OutInAxisOperationClient(this, sc, options);
+ }
+}
+
+/**
+ * MEP client for moi.
+ */
+class OutInAxisOperationClient implements OperationClient {
+
+ private OutInAxisOperation axisOp;
+
+ private ServiceContext sc;
+
+ private Options options;
+
+ private OperationContext oc;
+ private MessageReceiver mr;
+ /*
+ * indicates whether the MEP execution has completed (and hence ready for
+ * resetting)
+ */
+ boolean completed;
+
+ OutInAxisOperationClient(OutInAxisOperation axisOp, ServiceContext sc,
+ Options options) {
+ this.axisOp = axisOp;
+ this.sc = sc;
+ this.options = new Options(options);
+ this.completed = false;
+ this.oc = new OperationContext(axisOp);
+ this.oc.setParent(this.sc);
+ this.sc.getAxisService().addOperation(this.axisOp);
+ }
+
+ /**
+ * Sets the options that should be used for this particular client. This
+ * resets the entire set of options to use the new options - so you'd lose
+ * any option cascading that may have been set up.
+ *
+ * @param options the options
+ */
+ public void setOptions(Options options) {
+ this.options = options;
+ }
+
+ /**
+ * Return the options used by this client. If you want to set a single
+ * option, then the right way is to do getOptions() and set specific
+ * options.
+ *
+ * @return the options, which will never be null.
+ */
+ public Options getOptions() {
+ return options;
+ }
+
+ /**
+ * Adding message context to operation context , so that it will handle the logic correctly
+ * if the OperationContext is null then new one will be created , and oc will become null
+ * when some one call reset()
+ *
+ * @param mc
+ * @throws AxisFault
+ */
+ public void addMessageContext(MessageContext mc) throws AxisFault {
+ if (oc == null) {
+ oc = new OperationContext(axisOp);
+ oc.setParent(sc);
+ }
+ axisOp.registerOperationContext(mc, oc);
+ mc.setServiceContext(sc);
+ }
+
+ /**
+ * Retun the message context for a given message lebel
+ *
+ * @param messageLabel : label of the message and that can be either "Out" or "In" and
+ * nothing else
+ * @return
+ * @throws AxisFault
+ */
+ public MessageContext getMessageContext(String messageLabel)
+ throws AxisFault {
+ return oc.getMessageContext(messageLabel);
+ }
+
+ public void setMessageReceiver(MessageReceiver mr) {
+ this.mr = mr;
+ }
+
+ /**
+ * Execute the MEP. What this does depends on the specific MEP client. The
+ * basic idea is to have the MEP client execute and do something with the
+ * messages that have been added to it so far. For example, if its an Out-In
+ * MEP, then if the Out message has been set, then executing the client asks
+ * it to send the message and get the In message, possibly using a different
+ * thread.
+ *
+ * @param block Indicates whether execution should block or return ASAP. What
+ * block means is of course a function of the specific MEP
+ * client. IGNORED BY THIS MEP CLIENT.
+ * @throws AxisFault if something goes wrong during the execution of the MEP.
+ */
+ public void execute(boolean block) throws AxisFault {
+ if (completed) {
+ throw new AxisFault(
+ "MEP is already completed- need to reset() before re-executing.");
+ }
+ ConfigurationContext cc = sc.getConfigurationContext();
+
+ // copy interesting info from options to message context.
+ MessageContext mc = oc.getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
+ if (mc == null) {
+ throw new AxisFault("Out message context is null ," +
+ " please set the out message context before calling this method");
+ }
+ mc.setConfigurationContext(cc);
+ mc.setAxisOperation(axisOp);
+ mc.setServiceContext(sc);
+ ClientUtils.copyInfoFromOptionsToMessageContext(options,
+ mc);
+
+ // if the transport to use for sending is not specified, try to find it
+ // from the URL
+ TransportOutDescription senderTransport = options.getSenderTransport();
+ if (senderTransport == null) {
+ EndpointReference toEPR = (options.getTo() != null) ? options
+ .getTo() : mc.getTo();
+ senderTransport = ClientUtils.inferOutTransport(cc
+ .getAxisConfiguration(), toEPR);
+ }
+ mc.setTransportOut(senderTransport);
+ if (mc.getTransportIn() == null) {
+ TransportInDescription transportInDescription = options.getTransportInDescription();
+ if (transportInDescription == null) {
+ mc.setTransportIn(ClientUtils.inferInTransport(cc.getAxisConfiguration(),
+ options, mc.getServiceContext()));
+ } else {
+ mc.setTransportIn(transportInDescription);
+ }
+ }
+
+ //todo : need to improve this , no need to set AxisService if the service context is there in msgContext
+ mc.setAxisService(sc.getAxisService());
+
+ if (options.isUseSeparateListener())
+
+ {
+ CallbackReceiver callbackReceiver = (CallbackReceiver) mr;
+ axisOp.setMessageReceiver(callbackReceiver);
+ callbackReceiver.addCallback(mc.getMessageID(), options.getCallback());
+ EndpointReference replyToFromTransport =
+ ListenerManager
+ .replyToEPR(cc,
+ sc.getAxisService().getName() + "/"
+ + axisOp.getName().getLocalPart(), options
+ .getTransportInDescription().getName().getLocalPart());
+
+ if (mc.getReplyTo() == null) {
+ mc.setReplyTo(replyToFromTransport);
+ } else {
+ mc.getReplyTo().setAddress(replyToFromTransport.getAddress());
+ }
+ AxisEngine engine = new AxisEngine(cc);
+ engine.send(mc);
+ }
+
+ else
+
+ {
+ if (!block) {
+ // Send the SOAP Message and receive a response
+ MessageContext response = send(mc, options.getTransportInDescription());
+ // check for a fault and return the result
+ SOAPEnvelope resenvelope = response.getEnvelope();
+ if (resenvelope.getBody().hasFault()) {
+ SOAPFault soapFault = resenvelope.getBody().getFault();
+ Exception ex = soapFault.getException();
+
+ if (options.isExceptionToBeThrownOnSOAPFault()) {
+
+ // does the SOAPFault has a detail element for Excpetion
+ if (ex != null) {
+ throw new AxisFault(ex);
+ } else {
+
+ // if detail element not present create a new Exception from the detail
+ String message = "";
+
+ message = (message + "Code =" + soapFault.getCode() == null)
+ ? ""
+ : (soapFault.getCode().getValue() == null)
+ ? ""
+ : soapFault.getCode().getValue().getText();
+ message = (message + "Reason =" + soapFault.getReason() == null)
+ ? ""
+ : (soapFault.getReason().getSOAPText() == null)
+ ? ""
+ : soapFault.getReason().getSOAPText().getText();
+
+ throw new AxisFault(message);
+ }
+ }
+ }
+ completed = true;
+ } else {
+ sc.getConfigurationContext().getThreadPool().execute(
+ new NonBlockingInvocationWorker(options.getCallback(), mc));
+ }
+ }
+ }
+
+ /**
+ * Sends the message using a two way transport and waits for a response
+ *
+ * @param msgctx
+ * @param transportIn
+ * @return
+ * @throws AxisFault
+ */
+ public MessageContext send(MessageContext msgctx, TransportInDescription transportIn)
+ throws AxisFault {
+ AxisEngine engine = new AxisEngine(msgctx.getConfigurationContext());
+
+ engine.send(msgctx);
+
+// create the responseMessageContext
+ MessageContext responseMessageContext = new MessageContext(msgctx.getConfigurationContext(),
+ msgctx.getSessionContext(), msgctx.getTransportIn(),
+ msgctx.getTransportOut());
+
+ responseMessageContext.setProperty(MessageContext.TRANSPORT_IN,
+ msgctx.getProperty(MessageContext.TRANSPORT_IN));
+ addMessageContext(responseMessageContext);
+ responseMessageContext.setServerSide(false);
+ responseMessageContext.setServiceContext(msgctx.getServiceContext());
+ responseMessageContext.setServiceGroupContext(msgctx.getServiceGroupContext());
+
+// If request is REST we assume the responseMessageContext is REST, so set the variable
+ responseMessageContext.setDoingREST(msgctx.isDoingREST());
+
+ SOAPEnvelope resenvelope = TransportUtils.createSOAPMessage(responseMessageContext,
+ msgctx.getEnvelope().getNamespace().getName());
+
+ if (resenvelope != null) {
+ responseMessageContext.setEnvelope(resenvelope);
+ engine = new AxisEngine(msgctx.getConfigurationContext());
+ engine.receive(responseMessageContext);
+ } else {
+ throw new AxisFault(Messages.getMessage("blockingInvocationExpectsResponse"));
+ }
+
+ return responseMessageContext;
+ }
+
+ /**
+ * Reset the MEP client to a clean status after the MEP has completed. This
+ * is how you can reuse a MEP client. NOTE: this does not reset the options;
+ * only the internal state so the client can be used again.
+ *
+ * @throws AxisFault if reset is called before the MEP client has completed an
+ * interaction.
+ */
+ public void reset() throws AxisFault {
+ if (!completed) {
+ throw new AxisFault("MEP is not yet complete: cannot reset");
+ }
+ oc = null;
+ completed = false;
+ }
+
+ /**
+ * This class is the workhorse for a non-blocking invocation that uses a
+ * two way transport.
+ */
+ private class NonBlockingInvocationWorker implements Runnable {
+ private Callback callback;
+ private MessageContext msgctx;
+
+ public NonBlockingInvocationWorker(Callback callback, MessageContext msgctx) {
+ this.callback = callback;
+ this.msgctx = msgctx;
+ }
+
+ public void run() {
+ try {
+
+ // send the request and wait for reponse
+ MessageContext response = send(msgctx, options.getTransportInDescription());
+
+ // call the callback
+ SOAPEnvelope resenvelope = response.getEnvelope();
+ SOAPBody body = resenvelope.getBody();
+
+ if (body.hasFault()) {
+ Exception ex = body.getFault().getException();
+
+ if (ex != null) {
+ callback.reportError(ex);
+ } else {
+
+ // todo this needs to be fixed
+ callback.reportError(new Exception(body.getFault().getReason().getText()));
+ }
+ } else {
+ AsyncResult asyncResult = new AsyncResult(response);
+
+ callback.onComplete(asyncResult);
+ }
+
+ callback.setComplete(true);
+ } catch (Exception e) {
+ callback.reportError(e);
+ }
+ }
+ }
}
+
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/Utils.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/Utils.java?rev=359771&r1=359770&r2=359771&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/Utils.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/Utils.java Thu Dec 29 02:42:30 2005
@@ -22,12 +22,7 @@
import org.apache.axis2.addressing.AddressingConstants;
import org.apache.axis2.addressing.RelatesTo;
import org.apache.axis2.client.Options;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.ConfigurationContextFactory;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.context.OperationContext;
-import org.apache.axis2.context.ServiceContext;
-import org.apache.axis2.context.ServiceGroupContext;
+import org.apache.axis2.context.*;
import org.apache.axis2.description.*;
import org.apache.axis2.engine.AxisConfiguration;
import org.apache.axis2.engine.Handler;
@@ -51,8 +46,7 @@
flow.addHandler(handlerDesc);
}
- public static MessageContext createOutMessageContext(MessageContext inMessageContext)
- {
+ public static MessageContext createOutMessageContext(MessageContext inMessageContext) {
MessageContext newmsgCtx = new MessageContext(inMessageContext.getConfigurationContext(),
inMessageContext.getSessionContext(),
inMessageContext.getTransportIn(),
@@ -92,6 +86,11 @@
return createSimpleService(serviceName, new RawXMLINOutMessageReceiver(), className,
opName);
}
+ public static AxisService createSimpleServiceforClient(QName serviceName, String className, QName opName)
+ throws AxisFault {
+ return createSimpleServiceforClient(serviceName, new RawXMLINOutMessageReceiver(), className,
+ opName);
+ }
public static AxisService createSimpleService(QName serviceName,
MessageReceiver messageReceiver, String className, QName opName)
@@ -111,9 +110,28 @@
return service;
}
+ public static AxisService createSimpleServiceforClient(QName serviceName,
+ MessageReceiver messageReceiver,
+ String className,
+ QName opName)
+ throws AxisFault {
+ AxisService service = new AxisService(serviceName.getLocalPart());
+
+ service.setClassLoader(Thread.currentThread().getContextClassLoader());
+ service.addParameter(new ParameterImpl(AbstractMessageReceiver.SERVICE_CLASS, className));
+
+ // todo I assumed in-out mep , this has to be imroved : Deepal
+ AxisOperation axisOp = new OutInAxisOperation(opName);
+
+ axisOp.setMessageReceiver(messageReceiver);
+ axisOp.setStyle(WSDLService.STYLE_RPC);
+ service.addOperation(axisOp);
+
+ return service;
+ }
+
public static void extractServiceGroupAndServiceInfo(String filePart,
- MessageContext messageContext)
- {
+ MessageContext messageContext) {
String[] values = parseRequestURLForServiceAndOperation(filePart);
String serviceNameAndGroup = values[0];
@@ -145,8 +163,7 @@
}
public static ServiceContext fillContextInformation(AxisOperation axisOperation,
- AxisService axisService, ConfigurationContext configurationContext)
- {
+ AxisService axisService, ConfigurationContext configurationContext) {
// 2. if null, create new opCtxt
OperationContext operationContext = new OperationContext(axisOperation);
@@ -156,8 +173,7 @@
}
private static ServiceContext fillServiceContextAndServiceGroupContext(AxisService axisService,
- ConfigurationContext configurationContext)
- {
+ ConfigurationContext configurationContext) {
String serviceGroupContextId = UUIDGenerator.getUUID();
ServiceGroupContext serviceGroupContext = new ServiceGroupContext(configurationContext,
axisService.getParent());
Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/CallUnregisteredServiceTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/CallUnregisteredServiceTest.java?rev=359771&r1=359770&r2=359771&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/CallUnregisteredServiceTest.java (original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/CallUnregisteredServiceTest.java Thu Dec 29 02:42:30 2005
@@ -22,14 +22,14 @@
import org.apache.axis2.AxisFault;
import org.apache.axis2.Constants;
import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.client.Call;
import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
import org.apache.axis2.integration.UtilServer;
import org.apache.axis2.om.OMAbstractFactory;
import org.apache.axis2.om.OMElement;
import org.apache.axis2.om.OMNamespace;
-import org.apache.axis2.soap.SOAPBody;
-import org.apache.axis2.soap.SOAPEnvelope;
import org.apache.axis2.soap.SOAPFactory;
public class CallUnregisteredServiceTest extends TestCase {
@@ -63,26 +63,23 @@
"Isaac Asimov, The Foundation Trilogy"));
method.addChild(value);
- Call call = new Call("target/test-resources/integrationRepo");
EndpointReference targetEPR =
new EndpointReference("http://127.0.0.1:"
- + (UtilServer.TESTING_PORT)
- + "/axis/services/EchoXMLService1");
+ + (UtilServer.TESTING_PORT)
+ + "/axis/services/EchoXMLService1");
Options options = new Options();
- call.setClientOptions(options);
options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
options.setTo(targetEPR);
-
- SOAPEnvelope resEnv =
- (SOAPEnvelope) call.invokeBlocking(
- "echoOMElement", method);
-
- SOAPBody sb = resEnv.getBody();
- if (sb.hasFault()) {
- throw new AxisFault(
- sb.getFault().getReason().getSOAPText().getText());
- }
+
+ ConfigurationContextFactory factory = new ConfigurationContextFactory();
+ ConfigurationContext configContext =
+ factory.buildConfigurationContext("target/test-resources/integrationRepo");
+ ServiceClient sender = new ServiceClient(configContext);
+ sender.setOptions(options);
+ options.setTo(targetEPR);
+
+ sender.sendReceive(method);
fail("The test must fail due to wrong service Name");
} catch (AxisFault e) {
Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/CharactersetEncodingTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/CharactersetEncodingTest.java?rev=359771&r1=359770&r2=359771&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/CharactersetEncodingTest.java (original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/CharactersetEncodingTest.java Thu Dec 29 02:42:30 2005
@@ -21,6 +21,9 @@
import org.apache.axis2.Constants;
import org.apache.axis2.client.Call;
import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.description.AxisService;
import org.apache.axis2.engine.util.TestConstants;
@@ -75,15 +78,24 @@
text.addChild(fac.createText(text, value));
payload.addChild(text);
- Call call = new Call(
- Constants.TESTING_PATH + "chunking-enabledRepository");
+// Call call = new Call(
+// Constants.TESTING_PATH + "chunking-enabledRepository");
Options options = new Options();
- call.setClientOptions(options);
+// call.setClientOptions(options);
options.setProperty(MessageContext.CHARACTER_SET_ENCODING, "utf-16");
options.setTo(targetEPR);
options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
- OMElement resultElem = call.invokeBlocking(operationName.getLocalPart(), payload);
+// OMElement resultElem = call.invokeBlocking(operationName.getLocalPart(), payload);
+
+ ConfigurationContextFactory factory = new ConfigurationContextFactory();
+ ConfigurationContext configContext =
+ factory.buildConfigurationContext(Constants.TESTING_PATH + "chunking-enabledRepository");
+ ServiceClient sender = new ServiceClient(configContext);
+ sender.setOptions(options);
+ options.setTo(targetEPR);
+
+ OMElement resultElem = sender.sendReceive(payload);
assertNotNull("Result is null", resultElem);
@@ -93,10 +105,10 @@
assertEquals("Expected result not received.", expected, result);
- call.close();
+// call.close();
} catch (AxisFault e) {
- log.error(e,e);
+ log.error(e, e);
assertFalse("Failure in processing", true);
}
}
Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/CommonsHTTPEchoRawXMLTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/CommonsHTTPEchoRawXMLTest.java?rev=359771&r1=359770&r2=359771&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/CommonsHTTPEchoRawXMLTest.java (original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/CommonsHTTPEchoRawXMLTest.java Thu Dec 29 02:42:30 2005
@@ -21,8 +21,11 @@
import junit.framework.TestCase;
import org.apache.axis2.AxisFault;
import org.apache.axis2.Constants;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.client.Call;
import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.client.async.AsyncResult;
import org.apache.axis2.client.async.Callback;
import org.apache.axis2.description.AxisService;
@@ -70,11 +73,11 @@
public void testEchoXMLASync() throws Exception {
OMElement payload = TestingUtils.createDummyOMElement();
- Call call = new Call(
- Constants.TESTING_PATH + "commons-http-enabledRepository");
+// Call call = new Call(
+// Constants.TESTING_PATH + "commons-http-enabledRepository");
Options options = new Options();
- call.setClientOptions(options);
+// call.setClientOptions(options);
options.setTo(targetEPR);
options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
@@ -91,9 +94,19 @@
}
};
- call.invokeNonBlocking(operationName.getLocalPart(),
- payload,
- callback);
+// call.invokeNonBlocking(operationName.getLocalPart(),
+// payload,
+// callback);
+
+ ConfigurationContextFactory factory = new ConfigurationContextFactory();
+ ConfigurationContext configContext =
+ factory.buildConfigurationContext(Constants.TESTING_PATH + "commons-http-enabledRepository");
+ ServiceClient sender = new ServiceClient(configContext);
+ sender.setOptions(options);
+ options.setTo(targetEPR);
+
+ sender.sendReceiveNonblocking(payload,callback);
+
int index = 0;
while (!finish) {
Thread.sleep(1000);
@@ -103,8 +116,8 @@
"Server was shutdown as the async response take too long to complete");
}
}
- call.close();
-
+// call.close();
+//
log.info("send the reqest");
}
@@ -113,19 +126,29 @@
SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
OMElement payload = TestingUtils.createDummyOMElement();
- Call call = new Call(
- Constants.TESTING_PATH + "commons-http-enabledRepository");
+// Call call = new Call(
+// Constants.TESTING_PATH + "commons-http-enabledRepository");
Options options = new Options();
- call.setClientOptions(options);
+// call.setClientOptions(options);
options.setTo(targetEPR);
options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
- OMElement result =
- call.invokeBlocking(operationName.getLocalPart(),
- payload);
+// OMElement result =
+// call.invokeBlocking(operationName.getLocalPart(),
+// payload);
+
+ ConfigurationContextFactory factory = new ConfigurationContextFactory();
+ ConfigurationContext configContext =
+ factory.buildConfigurationContext(Constants.TESTING_PATH + "commons-http-enabledRepository");
+ ServiceClient sender = new ServiceClient(configContext);
+ sender.setOptions(options);
+ options.setTo(targetEPR);
+
+ OMElement result = sender.sendReceive(payload);
+
TestingUtils.campareWithCreatedOMElement(result);
- call.close();
+// call.close();
}
}
Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/EchoRawRuntimeProxyTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/EchoRawRuntimeProxyTest.java?rev=359771&r1=359770&r2=359771&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/EchoRawRuntimeProxyTest.java (original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/EchoRawRuntimeProxyTest.java Thu Dec 29 02:42:30 2005
@@ -4,6 +4,9 @@
import org.apache.axis2.Constants;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
import org.apache.axis2.description.AxisService;
import org.apache.axis2.integration.TestingUtils;
import org.apache.axis2.integration.UtilServer;
@@ -32,7 +35,7 @@
public class EchoRawRuntimeProxyTest extends TestCase {
public static final EndpointReference targetEPR = new EndpointReference(
- "http://apache.axis2.host"
+ "http://apache.axis2.host"
+ "/axis2/services/EchoXMLService/echoOMElement");
public static final QName serviceName = new QName("EchoXMLService");
@@ -68,10 +71,6 @@
public void testEchoXMLSync() throws Exception {
OMElement payload = TestingUtils.createDummyOMElement();
-
- org.apache.axis2.client.Call call =
- new org.apache.axis2.client.Call(
- "target/test-resources/integrationRepo");
/**
* Proxy setting in runtime
*/
@@ -83,16 +82,19 @@
proxyproperties.setUserName("anonymous");
Options options = new Options();
- call.setClientOptions(options);
options.setProperty(HTTPConstants.PROXY, proxyproperties);
options.setTo(targetEPR);
options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
- OMElement result =
- call.invokeBlocking(operationName.getLocalPart(),
- payload);
+ ConfigurationContextFactory factory = new ConfigurationContextFactory();
+ ConfigurationContext configContext =
+ factory.buildConfigurationContext("target/test-resources/integrationRepo");
+ ServiceClient sender = new ServiceClient(configContext);
+ sender.setOptions(options);
+ options.setTo(targetEPR);
+
+ OMElement result = sender.sendReceive(payload);
TestingUtils.campareWithCreatedOMElement(result);
- call.close();
}
}
Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/EchoRawXMLChunkedTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/EchoRawXMLChunkedTest.java?rev=359771&r1=359770&r2=359771&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/EchoRawXMLChunkedTest.java (original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/EchoRawXMLChunkedTest.java Thu Dec 29 02:42:30 2005
@@ -20,8 +20,11 @@
import junit.framework.TestCase;
import org.apache.axis2.Constants;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.client.Call;
import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.description.AxisService;
import org.apache.axis2.engine.util.TestConstants;
import org.apache.axis2.integration.TestingUtils;
@@ -103,21 +106,29 @@
// }
public void testEchoXMLSync() throws Exception {
- SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
-
OMElement payload = TestingUtils.createDummyOMElement();
Options clientOptions = new Options();
- Call call = new Call(CLIENT_HOME);
- call.setClientOptions(clientOptions);
+// Call call = new Call(CLIENT_HOME);
+// call.setClientOptions(clientOptions);
- clientOptions.setTo(targetEPR);
+// clientOptions.setTo(targetEPR);
clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
- OMElement result =
- call.invokeBlocking(operationName.getLocalPart(),
- payload);
+// OMElement result =
+// call.invokeBlocking(operationName.getLocalPart(),
+// payload);
+ ConfigurationContextFactory factory = new ConfigurationContextFactory();
+ ConfigurationContext configContext =
+ factory.buildConfigurationContext(CLIENT_HOME);
+ ServiceClient sender = new ServiceClient(configContext);
+ sender.setOptions(clientOptions);
+ clientOptions.setTo(targetEPR);
+
+ OMElement result = sender.sendReceive(payload);
+
+
TestingUtils.campareWithCreatedOMElement(result);
- call.close();
+// call.close();
}
}
Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/EchoRawXMLLoadTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/EchoRawXMLLoadTest.java?rev=359771&r1=359770&r2=359771&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/EchoRawXMLLoadTest.java (original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/EchoRawXMLLoadTest.java Thu Dec 29 02:42:30 2005
@@ -21,31 +21,18 @@
import junit.framework.TestCase;
import org.apache.axis2.Constants;
import org.apache.axis2.client.Options;
-import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
import org.apache.axis2.description.AxisService;
import org.apache.axis2.engine.util.TestConstants;
import org.apache.axis2.integration.TestingUtils;
import org.apache.axis2.integration.UtilServer;
-import org.apache.axis2.om.OMAbstractFactory;
import org.apache.axis2.om.OMElement;
-import org.apache.axis2.soap.SOAPFactory;
import org.apache.axis2.util.Utils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
public class EchoRawXMLLoadTest extends TestCase implements TestConstants {
- private Log log = LogFactory.getLog(getClass());
-
- private AxisConfiguration engineRegistry;
- private MessageContext mc;
- //private Thread thisThread;
- // private SimpleHTTPServer sas;
-// private ServiceContext serviceContext;
- private AxisService service;
-
- private boolean finish = false;
-
public EchoRawXMLLoadTest() {
super(EchoRawXMLLoadTest.class.getName());
}
@@ -56,7 +43,7 @@
protected void setUp() throws Exception {
UtilServer.start();
- service =
+ AxisService service =
Utils.createSimpleService(serviceName,
Echo.class.getName(),
operationName);
@@ -109,27 +96,19 @@
// }
public void testEchoXMLSync() throws Exception {
- SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
-
OMElement payload = TestingUtils.createDummyOMElement();
-
- org.apache.axis2.client.Call call =
- new org.apache.axis2.client.Call("target/test-resources/integrationRepo");
-
Options options = new Options();
- call.setClientOptions(options);
- options.setTo(targetEPR);
options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
- OMElement result =
- call.invokeBlocking(operationName.getLocalPart(),
- payload);
-
- OMElement result1 =
- call.invokeBlocking(operationName.getLocalPart(),
- payload);
+ ConfigurationContextFactory factory = new ConfigurationContextFactory();
+ ConfigurationContext configContext =
+ factory.buildConfigurationContext("target/test-resources/integrationRepo");
+ ServiceClient sender = new ServiceClient(configContext);
+ sender.setOptions(options);
+ options.setTo(targetEPR);
+
+ OMElement result = sender.sendReceive(payload);
TestingUtils.campareWithCreatedOMElement(result);
- call.close();
}
}
Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/EchoRawXMLMultipleTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/EchoRawXMLMultipleTest.java?rev=359771&r1=359770&r2=359771&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/EchoRawXMLMultipleTest.java (original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/EchoRawXMLMultipleTest.java Thu Dec 29 02:42:30 2005
@@ -19,8 +19,11 @@
import org.apache.axis2.AxisFault;
import org.apache.axis2.Constants;
import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
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.context.ServiceContext;
import org.apache.axis2.description.AxisService;
@@ -78,12 +81,7 @@
OMElement payload = TestingUtils.createDummyOMElement();
for (int i = 0; i < 5; i++) {
- org.apache.axis2.client.Call call =
- new org.apache.axis2.client.Call(
- "target/test-resources/integrationRepo");
Options options = new Options();
- call.setClientOptions(options);
- options.setTo(targetEPR);
options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
Callback callback = new Callback() {
@@ -99,10 +97,16 @@
finish = true;
}
};
+ ConfigurationContextFactory factory = new ConfigurationContextFactory();
+ ConfigurationContext configContext =
+ factory.buildConfigurationContext("target/test-resources/integrationRepo");
+ ServiceClient sender = new ServiceClient(configContext);
+ sender.setOptions(options);
+ options.setTo(targetEPR);
+
+ sender.sendReceiveNonblocking(payload, callback);
+
- call.invokeNonBlocking(operationName.getLocalPart(),
- payload,
- callback);
int index = 0;
while (!finish) {
Thread.sleep(1000);
@@ -112,7 +116,6 @@
"Server was shutdown as the async response take too long to complete");
}
}
- call.close();
}
@@ -122,13 +125,13 @@
public void testEchoXMLMultipleDuelASync() throws Exception {
OMElement payload = TestingUtils.createDummyOMElement();
+ ConfigurationContextFactory factory = new ConfigurationContextFactory();
+ ConfigurationContext configContext =
+ factory.buildConfigurationContext("target/test-resources/integrationRepo");
+ ServiceClient sender = new ServiceClient(configContext);
+
for (int i = 0; i < 5; i++) {
- org.apache.axis2.client.Call call =
- new org.apache.axis2.client.Call(
- "target/test-resources/integrationRepo");
Options options = new Options();
- call.setClientOptions(options);
- options.setTo(targetEPR);
options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
options.setUseSeparateListener(true);
@@ -146,9 +149,12 @@
}
};
- call.invokeNonBlocking(operationName.getLocalPart(),
- payload,
- callback);
+ sender.setOptions(options);
+ options.setTo(targetEPR);
+
+ sender.sendReceiveNonblocking(payload, callback);
+ System.out.println("send the request");
+
int index = 0;
while (!finish) {
Thread.sleep(1000);
@@ -158,10 +164,9 @@
"Server is shutdown as the Async response take too longs time");
}
}
- call.close();
+ sender.finalizeInvoke();
}
-
log.info("send the request");
}
@@ -170,42 +175,52 @@
OMElement payload = TestingUtils.createDummyOMElement();
for (int i = 0; i < 5; i++) {
- org.apache.axis2.client.Call call =
- new org.apache.axis2.client.Call(
- "target/test-resources/integrationRepo");
Options options = new Options();
- call.setClientOptions(options);
options.setTo(targetEPR);
options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
+ ConfigurationContextFactory factory = new ConfigurationContextFactory();
+ ConfigurationContext configContext =
+ factory.buildConfigurationContext("target/test-resources/integrationRepo");
+ ServiceClient sender = new ServiceClient(configContext);
+ sender.setOptions(options);
+ options.setTo(targetEPR);
+
+ OMElement result = sender.sendReceive(payload);
+
- OMElement result =
- call.invokeBlocking(operationName.getLocalPart(),
- payload);
TestingUtils.campareWithCreatedOMElement(result);
- call.close();
+ sender.finalizeInvoke();
}
}
public void testEchoXMLMultipleDuelSync() throws Exception {
- SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
-
OMElement payload = TestingUtils.createDummyOMElement();
for (int i = 0; i < 5; i++) {
- org.apache.axis2.client.Call call =
- new org.apache.axis2.client.Call(
- "target/test-resources/integrationRepo");
+// org.apache.axis2.client.Call call =
+// new org.apache.axis2.client.Call(
+// "target/test-resources/integrationRepo");
Options options = new Options();
- call.setClientOptions(options);
+// call.setClientOptions(options);
options.setTo(targetEPR);
options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
options.setUseSeparateListener(true);
- OMElement result =
- call.invokeBlocking(operationName.getLocalPart(),
- payload);
+// OMElement result =
+// call.invokeBlocking(operationName.getLocalPart(),
+// payload);
+ ConfigurationContextFactory factory = new ConfigurationContextFactory();
+ ConfigurationContext configContext =
+ factory.buildConfigurationContext("target/test-resources/integrationRepo");
+ ServiceClient sender = new ServiceClient(configContext);
+
+ sender.setOptions(options);
+
+ OMElement result = sender.sendReceive(payload);
+
TestingUtils.campareWithCreatedOMElement(result);
- call.close();
+ sender.finalizeInvoke();
+// call.close();
}
}
Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/EchoRawXMLOnTwoChannelsSyncTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/EchoRawXMLOnTwoChannelsSyncTest.java?rev=359771&r1=359770&r2=359771&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/EchoRawXMLOnTwoChannelsSyncTest.java (original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/EchoRawXMLOnTwoChannelsSyncTest.java Thu Dec 29 02:42:30 2005
@@ -18,8 +18,8 @@
import junit.framework.TestCase;
import org.apache.axis2.Constants;
-import org.apache.axis2.client.Call;
import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.context.ServiceContext;
import org.apache.axis2.description.AxisService;
import org.apache.axis2.engine.util.TestConstants;
@@ -37,11 +37,6 @@
public class EchoRawXMLOnTwoChannelsSyncTest extends TestCase implements TestConstants {
- private Log log = LogFactory.getLog(getClass());
-
- private boolean finish = false;
-
-
public EchoRawXMLOnTwoChannelsSyncTest() {
super(EchoRawXMLOnTwoChannelsSyncTest.class.getName());
}
@@ -71,7 +66,7 @@
public void testEchoXMLCompleteSync() throws Exception {
AxisService service =
- Utils.createSimpleService(serviceName,
+ Utils.createSimpleServiceforClient(serviceName,
Echo.class.getName(),
operationName);
@@ -85,19 +80,21 @@
OMElement value = fac.createOMElement("myValue", omNs);
value.setText("Isaac Asimov, The Foundation Trilogy");
method.addChild(value);
-
- Call call = new Call(serviceContext);
Options options = new Options();
- call.setClientOptions(options);
options.setTo(targetEPR);
options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
options.setUseSeparateListener(true);
options.setAction(operationName.getLocalPart());
- OMElement result = call.invokeBlocking(
- operationName.getLocalPart(), method);
+ ServiceClient sender = new ServiceClient(serviceContext);
+ sender.setCurrentOperationName(operationName);
+ sender.setOptions(options);
+ options.setTo(targetEPR);
+
+ OMElement result = sender.sendReceive(method);
+
TestingUtils.campareWithCreatedOMElement(result);
- call.close();
+ sender.finalizeInvoke();
}
Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/EchoRawXMLOnTwoChannelsTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/EchoRawXMLOnTwoChannelsTest.java?rev=359771&r1=359770&r2=359771&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/EchoRawXMLOnTwoChannelsTest.java (original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/EchoRawXMLOnTwoChannelsTest.java Thu Dec 29 02:42:30 2005
@@ -19,8 +19,8 @@
import junit.framework.TestCase;
import org.apache.axis2.AxisFault;
import org.apache.axis2.Constants;
-import org.apache.axis2.client.Call;
import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.client.async.AsyncResult;
import org.apache.axis2.client.async.Callback;
import org.apache.axis2.context.ServiceContext;
@@ -74,7 +74,7 @@
public void testEchoXMLCompleteASync() throws Exception {
AxisService service =
- Utils.createSimpleService(serviceName,
+ Utils.createSimpleServiceforClient(serviceName,
Echo.class.getName(),
operationName);
@@ -88,11 +88,12 @@
OMElement value = fac.createOMElement("myValue", omNs);
value.setText("Isaac Asimov, The Foundation Trilogy");
method.addChild(value);
+ ServiceClient sender = null;
- Call call =
- new Call(
- serviceContext);
- call.engageModule(new QName(Constants.MODULE_ADDRESSING));
+// Call call =
+// new Call(
+// serviceContext);
+// call.engageModule(new QName(Constants.MODULE_ADDRESSING));
try {
Options options = new Options();
@@ -100,13 +101,13 @@
options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
options.setUseSeparateListener(true);
options.setAction(operationName.getLocalPart());
- call.setClientOptions(options);
+// call.setClientOptions(options);
Callback callback = new Callback() {
public void onComplete(AsyncResult result) {
TestingUtils.campareWithCreatedOMElement(
result.getResponseEnvelope().getBody()
- .getFirstElement());
+ .getFirstElement());
finish = true;
}
@@ -116,9 +117,16 @@
}
};
- call.invokeNonBlocking(operationName.getLocalPart(),
- method,
- callback);
+ sender = new ServiceClient(serviceContext);
+ sender.setCurrentOperationName(operationName);
+ sender.setOptions(options);
+ options.setTo(targetEPR);
+
+ sender.sendReceiveNonblocking(method, callback);
+
+// call.invokeNonBlocking(operationName.getLocalPart(),
+// method,
+// callback);
int index = 0;
while (!finish) {
Thread.sleep(1000);
@@ -129,9 +137,9 @@
}
}
log.info("send the reqest");
- call.close();
+ sender.finalizeInvoke();
} finally {
- call.close();
+ sender.finalizeInvoke();
}
}
Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/EchoRawXMLTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/EchoRawXMLTest.java?rev=359771&r1=359770&r2=359771&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/EchoRawXMLTest.java (original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/EchoRawXMLTest.java Thu Dec 29 02:42:30 2005
@@ -21,19 +21,19 @@
import junit.framework.TestCase;
import org.apache.axis2.AxisFault;
import org.apache.axis2.Constants;
-import org.apache.axis2.client.Call;
import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
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.context.ServiceContext;
import org.apache.axis2.description.AxisService;
import org.apache.axis2.engine.util.TestConstants;
import org.apache.axis2.integration.TestingUtils;
import org.apache.axis2.integration.UtilServer;
-import org.apache.axis2.om.OMAbstractFactory;
import org.apache.axis2.om.OMElement;
-import org.apache.axis2.soap.SOAPFactory;
import org.apache.axis2.util.Utils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -79,12 +79,7 @@
public void testEchoXMLASync() throws Exception {
OMElement payload = TestingUtils.createDummyOMElement();
-
- Call call =
- new Call("target/test-resources/integrationRepo");
-
Options options = new Options();
- call.setClientOptions(options);
options.setTo(targetEPR);
options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
@@ -101,9 +96,14 @@
}
};
- call.invokeNonBlocking(operationName.getLocalPart(),
- payload,
- callback);
+ ConfigurationContextFactory factory = new ConfigurationContextFactory();
+ ConfigurationContext configContext =
+ factory.buildConfigurationContext("target/test-resources/integrationRepo");
+ ServiceClient sender = new ServiceClient(configContext);
+ sender.setOptions(options);
+ options.setTo(targetEPR);
+ sender.sendReceiveNonblocking(payload, callback);
+
int index = 0;
while (!finish) {
Thread.sleep(1000);
@@ -113,47 +113,46 @@
"Server was shutdown as the async response take too long to complete");
}
}
- call.close();
-
-
log.info("send the request");
}
public void testEchoXMLSync() throws Exception {
- SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
OMElement payload = TestingUtils.createDummyOMElement();
-
- Call call =
- new Call("target/test-resources/integrationRepo");
-
Options options = new Options();
- call.setClientOptions(options);
options.setTo(targetEPR);
options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
- OMElement result =
- call.invokeBlocking(operationName.getLocalPart(),
- payload);
+ ConfigurationContextFactory factory = new ConfigurationContextFactory();
+ ConfigurationContext configContext =
+ factory.buildConfigurationContext("target/test-resources/integrationRepo");
+ ServiceClient sender = new ServiceClient(configContext);
+ sender.setOptions(options);
+ options.setTo(targetEPR);
+
+ OMElement result = sender.sendReceive(payload);
+
TestingUtils.campareWithCreatedOMElement(result);
- call.close();
}
public void testCorrectSOAPEnvelope() throws Exception {
OMElement payload = TestingUtils.createDummyOMElement();
- Call call =
- new Call("target/test-resources/integrationRepo");
Options options = new Options();
- call.setClientOptions(options);
options.setTo(targetEPR);
options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
- OMElement result = call.invokeBlocking(
- operationName.getLocalPart(), payload);
+ ConfigurationContextFactory factory = new ConfigurationContextFactory();
+ ConfigurationContext configContext =
+ factory.buildConfigurationContext("target/test-resources/integrationRepo");
+ ServiceClient sender = new ServiceClient(configContext);
+ sender.setOptions(options);
+ options.setTo(targetEPR);
+
+ OMElement result = sender.sendReceive(payload);
+
TestingUtils.campareWithCreatedOMElement(result);
- call.close();
}
Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/FaultHandlingTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/FaultHandlingTest.java?rev=359771&r1=359770&r2=359771&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/FaultHandlingTest.java (original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/FaultHandlingTest.java Thu Dec 29 02:42:30 2005
@@ -24,31 +24,16 @@
import org.apache.axis2.engine.util.TestConstants;
import org.apache.axis2.integration.UtilServer;
import org.apache.axis2.om.OMAbstractFactory;
-import org.apache.axis2.soap.SOAP11Constants;
-import org.apache.axis2.soap.SOAP12Constants;
-import org.apache.axis2.soap.SOAPEnvelope;
-import org.apache.axis2.soap.SOAPFactory;
-import org.apache.axis2.soap.SOAPFault;
-import org.apache.axis2.soap.impl.llom.builder.StAXSOAPModelBuilder;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.apache.axis2.soap.*;
-import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
import java.io.File;
-import java.io.FileReader;
public class FaultHandlingTest extends TestCase implements TestConstants {
- private Log log = LogFactory.getLog(getClass());
-
protected String testResourceDir = "test-resources";
private MyInOutMEPClient inOutMEPClient;
-
- private boolean finish = false;
-
protected void setUp() throws Exception {
UtilServer.start();
inOutMEPClient = getMyInOutMEPClient();
@@ -113,16 +98,6 @@
options.setTo(targetEPR);
options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
return inOutMEPClient;
- }
-
- private SOAPEnvelope createEnvelope(String fileName) throws Exception {
- if (fileName == "" || fileName == null) {
- throw new Exception("A SOAP file name must be provided !!");
- }
- XMLStreamReader parser = XMLInputFactory.newInstance()
- .createXMLStreamReader(new FileReader(getTestResourceFile(fileName)));
-
- return (SOAPEnvelope) new StAXSOAPModelBuilder(parser, null).getDocumentElement();
}
public File getTestResourceFile(String relativePath) {