You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ng...@apache.org on 2007/02/14 22:13:53 UTC
svn commit: r507692 - in /webservices/axis2/trunk/java/modules/jaxws:
src/org/apache/axis2/jaxws/client/async/
src/org/apache/axis2/jaxws/core/controller/
test/org/apache/axis2/jaxws/message/ test/org/apache/axis2/jaxws/sample/
Author: ngallardo
Date: Wed Feb 14 13:13:53 2007
New Revision: 507692
URL: http://svn.apache.org/viewvc?view=rev&rev=507692
Log:
AXIS2-2171
Contributor: Mike Rheinheimer
Mike's patch for this issue.
Modified:
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/core/controller/AxisInvocationController.java
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/FaultTests.java
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/FaultyWebServiceTests.java
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=507692&r1=507691&r2=507692
==============================================================================
--- 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 14 13:13:53 2007
@@ -179,6 +179,7 @@
log.debug("A fault was found. Starting to process fault response.");
}
Throwable t = processFaultResponse();
+ // JAXWS 4.3.3 conformance bullet says to throw an ExecutionException from here
throw new ExecutionException(t);
}
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/AxisInvocationController.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/AxisInvocationController.java?view=diff&rev=507692&r1=507691&r2=507692
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/AxisInvocationController.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/AxisInvocationController.java Wed Feb 14 13:13:53 2007
@@ -22,6 +22,7 @@
import java.net.URL;
import java.util.Iterator;
import java.util.Map;
+import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import javax.xml.namespace.QName;
@@ -255,17 +256,30 @@
}
opClient.setCallback(cbf);
-
+
org.apache.axis2.context.MessageContext axisRequestMsgCtx = request.getAxisMessageContext();
try {
execute(opClient, false, axisRequestMsgCtx);
} catch(AxisFault af) {
- // TODO MIKE revisit?
- // do nothing here. The exception we get is from the endpoint,
- // and will be sitting on the message context. We need to save it
- // to process it through jaxws
- System.out.println("Swallowed Exception =" + af);
- af.printStackTrace(System.out);
+ if (log.isDebugEnabled()) {
+ log.debug(axisRequestMsgCtx.getLogIDString()+" AxisFault received from client: " + af.getMessage());
+ }
+ /*
+ * Save the exception on the callback. The client will learn about the error when they try to
+ * retrieve the async results via the Response.get(). "Errors that occur during the invocation
+ * are reported via an exception when the client attempts to retrieve the results of the operation."
+ * -- JAXWS 4.3.3
+ */
+
+ /*
+ * TODO: This is the appropriate thing to do here since the thrown exception may occur before
+ * we switch threads to the async thread. But... what happens if we've already switched over
+ * to the async thread? So far, it appears that the exception gets set on the FutureTask
+ * Concurrent object, and we never hit this scope. This means that later, when the client
+ * calls future.get(), no exception will be thrown despite what the spec says. The client can,
+ * however, retrieve errors via it's AsyncHandler.
+ */
+ cbf.onError(af);
}
return cbf.getFutureTask();
@@ -318,12 +332,16 @@
try {
execute(opClient, false, axisRequestMsgCtx);
} catch(AxisFault af) {
- // TODO MIKE revisit?
- // do nothing here. The exception we get is from the endpoint,
- // and will be sitting on the message context. We need to save it
- // to process it through jaxws
- System.out.println("Swallowed Exception =" + af);
- af.printStackTrace(System.out);
+ if (log.isDebugEnabled()) {
+ log.debug(axisRequestMsgCtx.getLogIDString()+" AxisFault received from client: " + af.getMessage());
+ }
+ /*
+ * Save the exception on the callback. The client will learn about the error when they try to
+ * retrieve the async results via the Response.get(). "Errors that occur during the invocation
+ * are reported via an exception when the client attempts to retrieve the results of the operation."
+ * -- JAXWS 4.3.3
+ */
+ pf.onError(af);
}
return resp;
@@ -650,6 +668,7 @@
boolean block,
org.apache.axis2.context.MessageContext msgContext) throws AxisFault{
// This assumes that we are on the ultimate execution thread
+
ThreadContextMigratorUtil.performMigrationToContext(Constants.THREAD_CONTEXT_MIGRATOR_LIST_ID, msgContext);
if (log.isDebugEnabled()) {
Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/FaultTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/FaultTests.java?view=diff&rev=507692&r1=507691&r2=507692
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/FaultTests.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/FaultTests.java Wed Feb 14 13:13:53 2007
@@ -84,6 +84,19 @@
+ "</env:Body>"
+ "</env:Envelope>";
+ // missing namespace for faultcode value
+ private final static String sampleSOAP12FaultEnvelope2 =
+ //"<?xml version='1.0' encoding='UTF-8'?>"
+ "<env:Envelope xmlns:env=\"http://www.w3.org/2003/05/soap-envelope\">"
+ + "<env:Body>"
+ + "<env:Fault>"
+ + "<env:Code><env:Value>Sender</env:Value></env:Code>"
+ + "<env:Reason><env:Text lang=\""+ Locale.getDefault().getLanguage() +"\">"
+ + faultString + "sampleSOAP12FaultEnvelope2</env:Text></env:Reason>"
+ + "</env:Fault>"
+ + "</env:Body>"
+ + "</env:Envelope>";
+
private static XMLInputFactory inputFactory = XMLInputFactory.newInstance();
public FaultTests() {
@@ -229,6 +242,39 @@
fail(e.toString());
}
}
+
+// public void testStringInflow4() throws Exception {
+//
+// try {
+// // On inbound, there will already be an OM
+// // which represents the message. The following code simulates the input
+// // OM
+// StringReader sr = new StringReader(sampleSOAP12FaultEnvelope2);
+// XMLStreamReader inflow = inputFactory.createXMLStreamReader(sr);
+// StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inflow, null);
+// OMElement omElement = builder.getSOAPEnvelope();
+//
+// // The JAX-WS layer creates a Message from the OM
+// MessageFactory mf = (MessageFactory)
+// FactoryRegistry.getFactory(MessageFactory.class);
+// Message m = mf.createFrom(omElement);
+//
+// assertTrue(m.isFault());
+//
+// if (m.isFault()) {
+// XMLFault x = m.getXMLFault();
+// assertEquals(faultString + "sampleSOAP12FaultEnvelope2", x.getReason().getText());
+// assertEquals("Sender", x.getCode().
+// toQName("http://www.w3.org/2003/05/soap-envelope").getLocalPart());
+// } else {
+// fail("Message should be marked as a fault.");
+// }
+//
+// } catch (Exception e) {
+// e.printStackTrace();
+// fail(e.toString());
+// }
+// }
}
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=507692&r1=507691&r2=507692
==============================================================================
--- 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 14 13:13:53 2007
@@ -14,12 +14,18 @@
import javax.xml.ws.soap.SOAPFaultException;
import junit.framework.TestCase;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
import org.apache.axis2.jaxws.sample.faults.FaultyWebServiceFault_Exception;
import org.apache.axis2.jaxws.sample.faults.FaultyWebServicePortType;
import org.apache.axis2.jaxws.sample.faults.FaultyWebServiceService;
import org.apache.axis2.jaxws.sample.wrap.sei.DocLitWrap;
import org.apache.axis2.jaxws.sample.wrap.sei.DocLitWrapService;
-
+import org.apache.axis2.jaxws.util.Constants;
+import org.apache.axis2.util.MessageContextBuilder;
+import org.apache.axis2.util.ThreadContextMigrator;
+import org.apache.axis2.util.ThreadContextMigratorUtil;
import org.test.faults.FaultyWebServiceResponse;
public class FaultyWebServiceTests extends TestCase {
@@ -124,6 +130,85 @@
}
+ public void testFaultyWebService_badEndpoint_AsyncCallback()
+ throws Exception {
+
+ String host = "this.is.a.bad.endpoint.terrible.in.fact";
+ String badEndpoint = "http://" + host;
+
+ 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,
+ badEndpoint);
+
+ 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();
+
+ // 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));
+
+ }
+
+ public void testFaultyWebService_badEndpoint_AsyncPolling()
+ throws Exception {
+
+ String host = "this.is.a.bad.endpoint.terrible.in.fact";
+ String badEndpoint = "http://" + host;
+
+ 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,
+ badEndpoint);
+
+ Future<?> future = proxy.faultyWebServiceAsync(1);
+ while (!future.isDone()) {
+ Thread.sleep(1000);
+ System.out.println("Async invocation incomplete");
+ }
+
+ Exception e = null;
+ try {
+ Object obj = future.get();
+ } catch (Exception ex) {
+ e = ex;
+ }
+
+ // 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 user defined fault types
*/
@@ -138,7 +223,7 @@
FaultyAsyncHandler callback = new FaultyAsyncHandler();
Future<?> future = proxy.faultyWebServiceAsync(1, callback);
-
+
while (!future.isDone()) {
Thread.sleep(1000);
System.out.println("Async invocation incomplete");
@@ -156,47 +241,7 @@
"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
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org