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 ng...@apache.org on 2007/02/07 09:59:06 UTC
svn commit: r504466 - in /webservices/axis2/trunk/java/modules/jaxws:
src/org/apache/axis2/jaxws/client/ src/org/apache/axis2/jaxws/client/async/
src/org/apache/axis2/jaxws/client/proxy/
test/org/apache/axis2/jaxws/dispatch/ test/org/apache/axis2/jaxws...
Author: ngallardo
Date: Wed Feb 7 00:59:05 2007
New Revision: 504466
URL: http://svn.apache.org/viewvc?view=rev&rev=504466
Log:
Fixed fault processing for JAX-WS async callback and polling.
Modified:
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/BaseDispatch.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/JAXBDispatchAsyncListener.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/XMLDispatchAsyncListener.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/AsyncResponse.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/AsyncUtils.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/CallbackFuture.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/PollingFuture.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/ProxyAsyncListener.java
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/AsyncCallback.java
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/StringDispatch.java
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/FaultyWebServiceTests.java
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faults/FaultyWebServicePortType.java
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faults/FaultyWebServicePortTypeImpl.java
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/BaseDispatch.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/BaseDispatch.java?view=diff&rev=504466&r1=504465&r2=504466
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/BaseDispatch.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/BaseDispatch.java Wed Feb 7 00:59:05 2007
@@ -125,19 +125,12 @@
MessageContext responseMsgCtx = invocationContext.getResponseMessageContext();
- Message responseMsg = responseMsgCtx.getMessage();
-
- if (responseMsg.isFault()) {
- XMLFault fault = responseMsg.getXMLFault();
- // 4.3.2 conformance bullet 1 requires a ProtocolException here
- ProtocolException pe = MethodMarshallerUtils.createSystemException(responseMsg.getXMLFault(), responseMsg);
- throw pe;
- }
- else if (responseMsgCtx.getLocalException() != null) {
- // use the factory, it'll throw the right thing:
- throw ExceptionFactory.makeWebServiceException(responseMsgCtx.getLocalException());
+ if (hasFaultResponse(responseMsgCtx)) {
+ WebServiceException wse = BaseDispatch.getFaultResponse(responseMsgCtx);
+ throw wse;
}
-
+
+ Message responseMsg = responseMsgCtx.getMessage();
Object returnObj = getValueFromMessage(responseMsg);
//Check to see if we need to maintain session state
@@ -350,6 +343,44 @@
public void setMode(Mode m) {
mode = m;
+ }
+
+ /**
+ * Returns the fault that is contained within the MessageContext for an invocation.
+ * If no fault exists, null will be returned.
+ *
+ * @param msgCtx
+ * @return
+ */
+ public static WebServiceException getFaultResponse(MessageContext msgCtx) {
+ Message msg = msgCtx.getMessage();
+ if (msg != null && msg.isFault()) {
+ //XMLFault fault = msg.getXMLFault();
+ // 4.3.2 conformance bullet 1 requires a ProtocolException here
+ ProtocolException pe = MethodMarshallerUtils.createSystemException(msg.getXMLFault(), msg);
+ return pe;
+ }
+ else if (msgCtx.getLocalException() != null) {
+ // use the factory, it'll throw the right thing:
+ return ExceptionFactory.makeWebServiceException(msgCtx.getLocalException());
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns a boolean indicating whether or not the MessageContext contained a fault.
+ *
+ * @param msgCtx
+ * @return
+ */
+ public boolean hasFaultResponse(MessageContext msgCtx) {
+ if (msgCtx.getMessage() != null && msgCtx.getMessage().isFault())
+ return true;
+ else if (msgCtx.getLocalException() != null)
+ return true;
+ else
+ return false;
}
/*
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/JAXBDispatchAsyncListener.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/JAXBDispatchAsyncListener.java?view=diff&rev=504466&r1=504465&r2=504466
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/JAXBDispatchAsyncListener.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/JAXBDispatchAsyncListener.java Wed Feb 7 00:59:05 2007
@@ -53,4 +53,8 @@
public Object getResponseValueObject(MessageContext mc) {
return JAXBDispatch.getValue(mc.getMessage(), mode, jaxbContext);
}
+
+ public Throwable getFaultResponse(MessageContext mc) {
+ return BaseDispatch.getFaultResponse(mc);
+ }
}
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/XMLDispatchAsyncListener.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/XMLDispatchAsyncListener.java?view=diff&rev=504466&r1=504465&r2=504466
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/XMLDispatchAsyncListener.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/XMLDispatchAsyncListener.java Wed Feb 7 00:59:05 2007
@@ -45,4 +45,8 @@
public Object getResponseValueObject(MessageContext mc) {
return XMLDispatch.getValue(mc.getMessage(), mode, blockFactoryType);
}
+
+ public Throwable getFaultResponse(MessageContext mc) {
+ return BaseDispatch.getFaultResponse(mc);
+ }
}
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/AsyncResponse.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/AsyncResponse.java?view=diff&rev=504466&r1=504465&r2=504466
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/AsyncResponse.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/AsyncResponse.java Wed Feb 7 00:59:05 2007
@@ -28,10 +28,8 @@
import javax.xml.ws.Response;
-import org.apache.axiom.om.OMElement;
import org.apache.axis2.jaxws.ExceptionFactory;
import org.apache.axis2.jaxws.core.MessageContext;
-import org.apache.axis2.jaxws.message.Message;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -43,15 +41,18 @@
* object that is returned as the response along with a <link>java.util.Map</link>
* with the context information of the response.
*/
-public class AsyncResponse implements Response {
+public abstract class AsyncResponse implements Response {
private static final Log log = LogFactory.getLog(AsyncResponse.class);
- private static final boolean debug = log.isDebugEnabled();
private boolean cancelled;
+
+ private Throwable fault;
+ private MessageContext faultMessageContext;
private MessageContext response;
+
private Map<String, Object> responseContext;
- private Throwable fault;
+
private CountDownLatch latch;
private boolean cacheValid = false;
private Object cachedObject = null;
@@ -60,26 +61,26 @@
latch = new CountDownLatch(1);
}
- protected void onError(Throwable t) {
- if (debug) {
+ protected void onError(Throwable flt, MessageContext faultCtx) {
+ if (log.isDebugEnabled()) {
log.debug("AsyncResponse received a fault. Counting down latch.");
- log.debug("Fault type = " + t.getClass());
}
-
- fault = t;
- latch.countDown();
+
+ fault = flt;
+ faultMessageContext = faultCtx;
// Probably a good idea to invalidate the cache
cacheValid = false;
cachedObject = null;
-
- if (debug) {
+
+ latch.countDown();
+ if (log.isDebugEnabled()) {
log.debug("New latch count = [" + latch.getCount() + "]");
}
}
protected void onComplete(MessageContext mc) {
- if (debug) {
+ if (log.isDebugEnabled()) {
log.debug("AsyncResponse received a MessageContext. Counting down latch.");
}
@@ -93,7 +94,7 @@
response = mc;
latch.countDown();
- if (debug) {
+ if (log.isDebugEnabled()) {
log.debug("New latch count = [" + latch.getCount() + "]");
}
}
@@ -106,7 +107,7 @@
// The task cannot be cancelled if it has already been cancelled
// before or if it has already completed.
if (cancelled || latch.getCount() == 0) {
- if (debug) {
+ if (log.isDebugEnabled()) {
log.debug("Cancellation attempt failed.");
}
return false;
@@ -122,12 +123,12 @@
}
// Wait for the response to come back
- if (debug) {
+ if (log.isDebugEnabled()) {
log.debug("Waiting for async response delivery.");
}
latch.await();
- Object obj = processAsyncResponse(response);
+ Object obj = processResponse();
return obj;
}
@@ -137,7 +138,7 @@
}
// Wait for the response to come back
- if (debug) {
+ if (log.isDebugEnabled()) {
log.debug("Waiting for async response delivery with time out.");
log.debug("timeout = " + timeout);
log.debug("units = " + unit);
@@ -150,7 +151,7 @@
throw new TimeoutException("The client timed out while waiting for an asynchronous response");
}
- Object obj = processAsyncResponse(response);
+ Object obj = processResponse();
return obj;
}
@@ -166,22 +167,23 @@
return responseContext;
}
- private boolean hasFault() {
- if (fault != null)
- return true;
- else
- return false;
- }
-
private void initResponseContext() {
responseContext = new HashMap<String, Object>();
}
- private Object processAsyncResponse(MessageContext ctx) throws ExecutionException {
- if (hasFault()) {
- throw new ExecutionException(ExceptionFactory.makeWebServiceException(fault));
+ private Object processResponse() throws ExecutionException {
+ // If the fault object is not null, then we've received a fault message and
+ // we need to process it in one of a number of forms.
+ if (fault != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("A fault was found. Starting to process fault response.");
+ }
+ Throwable t = processFaultResponse();
+ throw new ExecutionException(t);
}
- if (ctx == null) {
+
+ // If we don't have a fault, then we have to have a MessageContext for the response.
+ if (response == null) {
throw new ExecutionException(ExceptionFactory.makeWebServiceException("null response"));
}
@@ -198,22 +200,22 @@
// the parameterized generic type.
Object obj = null;
try {
- if (debug) {
+ if (log.isDebugEnabled()) {
log.debug("Unmarshalling the async response message.");
}
- obj = getResponseValueObject(ctx);
+ obj = getResponseValueObject(response);
// Cache the object in case it is required again
cacheValid = true;
cachedObject = obj;
}
catch (Throwable t) {
- if (debug) {
+ if (log.isDebugEnabled()) {
log.debug("An error occurred while processing the response");
}
throw new ExecutionException(ExceptionFactory.makeWebServiceException(t));
}
- if (debug && obj != null) {
+ if (log.isDebugEnabled() && obj != null) {
log.debug("Unmarshalled response object of type: " + obj.getClass());
}
@@ -222,19 +224,25 @@
return obj;
}
- /**
- * A default implementation of this method that returns the contents
- * of the message in the form of an XML String. Subclasses should override
- * this to convert the response message into whatever format they require.
- * @param msg
- */
- protected Object getResponseValueObject(MessageContext mc) {
- if (log.isDebugEnabled()) {
- log.debug("Demarshalling response message as a String");
- }
- Message msg = mc.getMessage();
- OMElement om = msg.getAsOMElement();
- return om.toString();
+ private Throwable processFaultResponse() {
+ // A faultMessageContext means that there could possibly be a SOAPFault
+ // on the MessateContext that we need to unmarshall.
+ if (faultMessageContext != null) {
+ Throwable t = getFaultResponse(faultMessageContext);
+ if (t != null) {
+ return ExceptionFactory.makeWebServiceException(t);
+ }
+ else {
+ return ExceptionFactory.makeWebServiceException(fault);
+ }
+ }
+ else {
+ return ExceptionFactory.makeWebServiceException(fault);
+ }
}
+
+ public abstract Object getResponseValueObject(MessageContext mc);
+
+ public abstract Throwable getFaultResponse(MessageContext mc);
}
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/AsyncUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/AsyncUtils.java?view=diff&rev=504466&r1=504465&r2=504466
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/AsyncUtils.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/AsyncUtils.java Wed Feb 7 00:59:05 2007
@@ -33,7 +33,11 @@
private static final Log log = LogFactory.getLog(AsyncUtils.class);
private static final boolean debug = log.isDebugEnabled();
- public static MessageContext createMessageContext(AsyncResult result) throws WebServiceException {
+ public static MessageContext createJAXWSMessageContext(AsyncResult result) throws WebServiceException {
+ return AsyncUtils.createJAXWSMessageContext(result.getResponseMessageContext());
+ }
+
+ public static MessageContext createJAXWSMessageContext(org.apache.axis2.context.MessageContext mc) throws WebServiceException {
MessageContext response = null;
if (debug) {
@@ -41,17 +45,16 @@
}
// Create the JAX-WS response MessageContext from the Axis2 response
- org.apache.axis2.context.MessageContext axisResponse = result.getResponseMessageContext();
- response = new MessageContext(axisResponse);
+ response = new MessageContext(mc);
// REVIEW: Are we on the final thread of execution here or does this get handed off to the executor?
// TODO: Remove workaround for WS-Addressing running in thin client (non-server) environment
try {
- ThreadContextMigratorUtil.performMigrationToThread(Constants.THREAD_CONTEXT_MIGRATOR_LIST_ID, axisResponse);
+ ThreadContextMigratorUtil.performMigrationToThread(Constants.THREAD_CONTEXT_MIGRATOR_LIST_ID, mc);
}
catch (Throwable t) {
if (debug) {
- log.debug(axisResponse.getLogIDString()+" An error occurred in the ThreadContextMigratorUtil " + t);
+ log.debug(mc.getLogIDString()+" An error occurred in the ThreadContextMigratorUtil " + t);
log.debug("...caused by " + t.getCause());
}
throw ExceptionFactory.makeWebServiceException(t);
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/CallbackFuture.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/CallbackFuture.java?view=diff&rev=504466&r1=504465&r2=504466
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/CallbackFuture.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/CallbackFuture.java Wed Feb 7 00:59:05 2007
@@ -26,6 +26,7 @@
import javax.xml.ws.AsyncHandler;
import javax.xml.ws.WebServiceException;
+import org.apache.axis2.AxisFault;
import org.apache.axis2.client.async.AsyncResult;
import org.apache.axis2.client.async.Callback;
import org.apache.axis2.jaxws.core.MessageContext;
@@ -86,7 +87,7 @@
MessageContext response = null;
try {
- response = AsyncUtils.createMessageContext(result);
+ response = AsyncUtils.createJAXWSMessageContext(result);
} catch (WebServiceException e) {
cft.setError(e);
if (debug) {
@@ -104,8 +105,27 @@
@Override
public void onError(Exception e) {
- cft.setError(e);
- execute();
+ // If a SOAPFault was returned by the AxisEngine, the AxisFault
+ // that is returned should have a MessageContext with it. Use
+ // this to unmarshall the fault included there.
+ if (e.getClass().isAssignableFrom(AxisFault.class)) {
+ AxisFault fault = (AxisFault) e;
+ MessageContext faultMessageContext = null;
+ try {
+ faultMessageContext = AsyncUtils.createJAXWSMessageContext(fault.getFaultMessageContext());
+ }
+ catch (WebServiceException wse) {
+ cft.setError(wse);
+ }
+
+ cft.setError(e);
+ cft.setMessageContext(faultMessageContext);
+ }
+ else {
+ cft.setError(e);
+ }
+
+ execute();
}
private void execute() {
@@ -139,7 +159,7 @@
private static final boolean debug = log.isDebugEnabled();
AsyncResponse response;
- MessageContext responseMsgCtx;
+ MessageContext msgCtx;
AsyncHandler handler;
Exception error;
@@ -149,7 +169,7 @@
}
void setMessageContext(MessageContext mc) {
- responseMsgCtx = mc;
+ msgCtx = mc;
}
void setError(Exception e) {
@@ -158,13 +178,17 @@
@SuppressWarnings("unchecked")
public Object call() throws Exception {
- if (responseMsgCtx != null) {
- response.onComplete(responseMsgCtx);
+ // Set the response or fault content on the AsyncResponse object
+ // so that it can be collected inside the Executor thread and processed.
+ if (error != null) {
+ response.onError(error, msgCtx);
}
- else if (error != null) {
- response.onError(error);
+ else {
+ response.onComplete(msgCtx);
}
+ // Now that the content is available, call the JAX-WS AsyncHandler class
+ // to deliver the response to the user.
try {
if (debug) {
log.debug("Calling JAX-WS AsyncHandler with the Response object");
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/PollingFuture.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/PollingFuture.java?view=diff&rev=504466&r1=504465&r2=504466
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/PollingFuture.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/PollingFuture.java Wed Feb 7 00:59:05 2007
@@ -20,6 +20,7 @@
import javax.xml.ws.WebServiceException;
+import org.apache.axis2.AxisFault;
import org.apache.axis2.client.async.AsyncResult;
import org.apache.axis2.client.async.Callback;
import org.apache.axis2.jaxws.core.MessageContext;
@@ -45,9 +46,9 @@
MessageContext responseMsgCtx = null;
try {
- responseMsgCtx = AsyncUtils.createMessageContext(result);
+ responseMsgCtx = AsyncUtils.createJAXWSMessageContext(result);
} catch (WebServiceException e) {
- response.onError(e);
+ response.onError(e, null);
if (debug) {
log.debug("An error occured while processing the async response. " + e.getMessage());
}
@@ -62,7 +63,24 @@
@Override
public void onError(Exception e) {
- response.onError(e);
+ // If a SOAPFault was returned by the AxisEngine, the AxisFault
+ // that is returned should have a MessageContext with it. Use
+ // this to unmarshall the fault included there.
+ if (e.getClass().isAssignableFrom(AxisFault.class)) {
+ AxisFault fault = (AxisFault) e;
+ MessageContext faultMessageContext = null;
+ try {
+ faultMessageContext = AsyncUtils.createJAXWSMessageContext(fault.getFaultMessageContext());
+ }
+ catch (WebServiceException wse) {
+ response.onError(wse, null);
+ }
+
+ response.onError(e, faultMessageContext);
+ }
+ else {
+ response.onError(e, null);
+ }
}
}
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java?view=diff&rev=504466&r1=504465&r2=504466
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java Wed Feb 7 00:59:05 2007
@@ -313,23 +313,44 @@
if (log.isDebugEnabled()) {
log.debug("Converting Message to Response Object");
}
- if (responseMsg.isFault()) {
- Object object = MethodMarshallerFactory.getMarshaller(operationDesc, false).demarshalFaultResponse(responseMsg, operationDesc);
- if (log.isDebugEnabled()) {
- log.debug("Message Converted to response Throwable. Throwing back to client.");
- }
-
- throw (Throwable)object;
- } else if (responseContext.getLocalException() != null) {
- // use the factory, it'll throw the right thing:
- throw ExceptionFactory.makeWebServiceException(responseContext.getLocalException());
- }
+
+ if (hasFaultResponse(responseContext)) {
+ Throwable t = getFaultResponse(responseContext, operationDesc);
+ throw t;
+ }
+
Object object = MethodMarshallerFactory.getMarshaller(operationDesc, false).demarshalResponse(responseMsg, args, operationDesc);
if (log.isDebugEnabled()) {
log.debug("Message Converted to response Object");
}
return object;
}
+
+ protected static Throwable getFaultResponse(MessageContext msgCtx, OperationDescription opDesc) {
+ Message msg = msgCtx.getMessage();
+ if (msg!= null && msg.isFault()) {
+ Object object = MethodMarshallerFactory.getMarshaller(opDesc, false).demarshalFaultResponse(msg, opDesc);
+ if (log.isDebugEnabled()) {
+ log.debug("Message Converted to response Throwable. Throwing back to client.");
+ }
+
+ return (Throwable) object;
+ } else if (msgCtx.getLocalException() != null) {
+ // use the factory, it'll throw the right thing:
+ return ExceptionFactory.makeWebServiceException(msgCtx.getLocalException());
+ }
+
+ return null;
+ }
+
+ protected static boolean hasFaultResponse(MessageContext mc) {
+ if (mc.getMessage() != null && mc.getMessage().isFault())
+ return true;
+ else if (mc.getLocalException() != null)
+ return true;
+ else
+ return false;
+ }
private boolean isBindingProviderInvoked(Method method){
Class methodsClass = method.getDeclaringClass();
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/ProxyAsyncListener.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/ProxyAsyncListener.java?view=diff&rev=504466&r1=504465&r2=504466
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/ProxyAsyncListener.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/ProxyAsyncListener.java Wed Feb 7 00:59:05 2007
@@ -51,9 +51,10 @@
this.inputArgs = inputArgs;
}
+ @Override
public Object getResponseValueObject(MessageContext mc) {
try{
- //I will delegate the request to create respose to proxyHandler
+ //Delegate the request to create respose to proxyHandler
//since it has all the logic written to create response for Sync
//and oneWay.
return handler.createResponse(null,inputArgs, mc, operationDesc);
@@ -62,4 +63,9 @@
throw ExceptionFactory.makeWebServiceException(e);
}
}
+
+ @Override
+ public Throwable getFaultResponse(MessageContext mc) {
+ return JAXWSProxyHandler.getFaultResponse(mc, operationDesc);
+ }
}
Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/AsyncCallback.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/AsyncCallback.java?view=diff&rev=504466&r1=504465&r2=504466
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/AsyncCallback.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/AsyncCallback.java Wed Feb 7 00:59:05 2007
@@ -13,10 +13,8 @@
public void handleResponse(Response<T> response) {
try {
value = response.get();
- } catch (InterruptedException e) {
- exception = e;
- } catch (ExecutionException e) {
- exception = e;
+ } catch (Throwable t) {
+ exception = t;
}
}
Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/StringDispatch.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/StringDispatch.java?view=diff&rev=504466&r1=504465&r2=504466
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/StringDispatch.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/StringDispatch.java Wed Feb 7 00:59:05 2007
@@ -334,11 +334,19 @@
if (callback.hasError()) {
Throwable t = callback.getError();
- assertTrue(t instanceof ExecutionException);
- assertTrue(t.getCause() instanceof WebServiceException);
- assertTrue(t.getCause().getCause() instanceof UnknownHostException);
+ t.printStackTrace();
+
+ assertTrue(t.getClass().getName() + " does not match expected type ExecutionException", t instanceof ExecutionException);
+
+ Throwable cause = t.getCause();
+ assertNotNull("There must be a cause under the ExecutionException", cause);
+ assertTrue(cause.getClass().getName() + " does not match expected type WebServiceException" ,cause instanceof WebServiceException);
+
+ Throwable hostException = t.getCause().getCause();
+ assertNotNull("There must be a cause under the WebServiceException", hostException);
+ assertTrue(hostException.getClass().getName() + " does not match expected type UnknownHostException", hostException instanceof UnknownHostException);
} else {
- fail("Should have retrieved an UnknownHostException from callback");
+ fail("No fault thrown. Should have retrieved an UnknownHostException from callback");
}
}
Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/FaultyWebServiceTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/FaultyWebServiceTests.java?view=diff&rev=504466&r1=504465&r2=504466
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/FaultyWebServiceTests.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/FaultyWebServiceTests.java Wed Feb 7 00:59:05 2007
@@ -4,9 +4,14 @@
package org.apache.axis2.jaxws.sample;
import java.net.UnknownHostException;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import javax.xml.ws.AsyncHandler;
import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Response;
import javax.xml.ws.WebServiceException;
+import javax.xml.ws.soap.SOAPFaultException;
import junit.framework.TestCase;
import org.apache.axis2.jaxws.sample.faults.FaultyWebServiceFault_Exception;
@@ -15,6 +20,8 @@
import org.apache.axis2.jaxws.sample.wrap.sei.DocLitWrap;
import org.apache.axis2.jaxws.sample.wrap.sei.DocLitWrapService;
+import org.test.faults.FaultyWebServiceResponse;
+
public class FaultyWebServiceTests extends TestCase {
String axisEndpoint = "http://localhost:8080/axis2/services/FaultyWebServiceService";
public void testFaultyWebService(){
@@ -115,6 +122,104 @@
assertTrue(exception.getCause() instanceof UnknownHostException);
assertEquals(exception.getCause().getMessage(), host);
+ }
+
+ /*
+ * Tests fault processing for user defined fault types
+ */
+ public void testCustomFault_AsyncCallback() throws Exception {
+ System.out.println("------------------------------");
+ System.out.println("test: " + getName());
+
+ FaultyWebServiceService service = new FaultyWebServiceService();
+ FaultyWebServicePortType proxy = service.getFaultyWebServicePort();
+ BindingProvider p = (BindingProvider) proxy;
+ p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, axisEndpoint);
+
+ FaultyAsyncHandler callback = new FaultyAsyncHandler();
+ Future<?> future = proxy.faultyWebServiceAsync(1, callback);
+
+ while (!future.isDone()) {
+ Thread.sleep(1000);
+ System.out.println("Async invocation incomplete");
+ }
+
+ Exception e = callback.getException();
+ e.printStackTrace();
+
+ // Section 4.3.3 states that the top level Exception should be
+ // an ExecutionException, with a WebServiceException underneath.
+ assertNotNull("The exception was null.", e);
+ assertTrue("The thrown exception should be an ExecutionException.",
+ e.getClass().equals(ExecutionException.class));
+ assertTrue("The expected fault type under the ExecutionException should be a " +
+ "SOAPFaultException. Found type: " + e.getCause().getClass(),
+ e.getCause().getClass().isAssignableFrom(SOAPFaultException.class));
+ }
+
+// /*
+// * Tests fault processing for generic faults that may
+// * occur on the server.
+// */
+// public void testGenericFault_AsyncCallback() {
+// System.out.println("------------------------------");
+// System.out.println("test: " + getName());
+//
+// FaultyWebServiceService service = new FaultyWebServiceService();
+// FaultyWebServicePortType proxy = service.getFaultyWebServicePort();
+// BindingProvider p = (BindingProvider) proxy;
+// p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,axisEndpoint);
+// }
+//
+// /*
+// * Tests fault processing for user defined fault types
+// */
+// public void testCustomFault_AsyncPolling() {
+// System.out.println("------------------------------");
+// System.out.println("test: " + getName());
+//
+// FaultyWebServiceService service = new FaultyWebServiceService();
+// FaultyWebServicePortType proxy = service.getFaultyWebServicePort();
+// BindingProvider p = (BindingProvider) proxy;
+// p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,axisEndpoint);
+// }
+//
+// /*
+// * Tests fault processing for generic faults that may
+// * occur on the server.
+// */
+// public void testGenericFault_AsyncPolling() {
+// System.out.println("------------------------------");
+// System.out.println("test: " + getName());
+//
+// FaultyWebServiceService service = new FaultyWebServiceService();
+// FaultyWebServicePortType proxy = service.getFaultyWebServicePort();
+// BindingProvider p = (BindingProvider) proxy;
+// p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,axisEndpoint);
+// }
+
+ /*
+ * A callback implementation that can be used to collect the exceptions
+ */
+ class FaultyAsyncHandler implements AsyncHandler<FaultyWebServiceResponse> {
+
+ Exception exception;
+
+ public void handleResponse(Response<FaultyWebServiceResponse> response) {
+ try {
+ System.out.println("FaultyAsyncHandler.handleResponse() was called");
+ FaultyWebServiceResponse r = response.get();
+ System.out.println("No exception was thrown from Response.get()");
+ }
+ catch (Exception e) {
+ System.out.println("An exception was thrown: " + e.getClass());
+ exception = e;
+ }
+ }
+
+ public Exception getException() {
+ return exception;
+ }
}
}
Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faults/FaultyWebServicePortType.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faults/FaultyWebServicePortType.java?view=diff&rev=504466&r1=504465&r2=504466
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faults/FaultyWebServicePortType.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faults/FaultyWebServicePortType.java Wed Feb 7 00:59:05 2007
@@ -1,19 +1,19 @@
package org.apache.axis2.jaxws.sample.faults;
+import java.util.concurrent.Future;
+
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
+import javax.xml.ws.AsyncHandler;
import javax.xml.ws.RequestWrapper;
+import javax.xml.ws.Response;
import javax.xml.ws.ResponseWrapper;
-/**
- * This class was generated by the JAXWS SI.
- * JAX-WS RI 2.0_01-b15-fcs
- * Generated source version: 2.0
- *
- */
+import org.test.faults.FaultyWebServiceResponse;
+
@WebService(name = "FaultyWebServicePortType", targetNamespace = "http://org/test/faults")
public interface FaultyWebServicePortType {
@@ -35,5 +35,34 @@
int arg0)
throws FaultyWebServiceFault_Exception
;
+
+ /**
+ *
+ * @param asyncHandler
+ * @param arg0
+ * @return
+ * returns java.util.concurrent.Future<? extends java.lang.Object>
+ */
+ @WebMethod(operationName = "faultyWebService")
+ @RequestWrapper(localName = "faultyWebService", targetNamespace = "http://org/test/faults", className = "org.test.faults.FaultyWebService")
+ @ResponseWrapper(localName = "faultyWebServiceResponse", targetNamespace = "http://org/test/faults", className = "org.test.faults.FaultyWebServiceResponse")
+ public Future<?> faultyWebServiceAsync(
+ @WebParam(name = "arg0", targetNamespace = "http://org/test/faults")
+ int arg0,
+ @WebParam(name = "asyncHandler", targetNamespace = "")
+ AsyncHandler<FaultyWebServiceResponse> asyncHandler);
+
+ /**
+ *
+ * @param arg0
+ * @return
+ * returns javax.xml.ws.Response<org.test.faults.FaultyWebServiceResponse>
+ */
+ @WebMethod(operationName = "faultyWebService")
+ @RequestWrapper(localName = "faultyWebService", targetNamespace = "http://org/test/faults", className = "org.test.faults.FaultyWebService")
+ @ResponseWrapper(localName = "faultyWebServiceResponse", targetNamespace = "http://org/test/faults", className = "org.test.faults.FaultyWebServiceResponse")
+ public Response<FaultyWebServiceResponse> faultyWebServiceAsync(
+ @WebParam(name = "arg0", targetNamespace = "http://org/test/faults")
+ int arg0);
}
Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faults/FaultyWebServicePortTypeImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faults/FaultyWebServicePortTypeImpl.java?view=diff&rev=504466&r1=504465&r2=504466
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faults/FaultyWebServicePortTypeImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faults/FaultyWebServicePortTypeImpl.java Wed Feb 7 00:59:05 2007
@@ -7,9 +7,8 @@
import org.test.faults.FaultyWebServiceFault;
-
@WebService(endpointInterface="org.apache.axis2.jaxws.sample.faults.FaultyWebServicePortType")
-public class FaultyWebServicePortTypeImpl implements FaultyWebServicePortType {
+public class FaultyWebServicePortTypeImpl {
/* (non-Javadoc)
* @see org.apache.axis2.jaxws.sample.faults.FaultyWebServicePortType#faultyWebService(int)
@@ -21,11 +20,6 @@
bean.setMessage("bean custom message");
throw new FaultyWebServiceFault_Exception("custom exception", bean);
-// throw new RuntimeException("runtime exception");
-
- // TODO Auto-generated method stub
- //return arg0+3;
-
}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org