axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From barre...@apache.org
Subject svn commit: r470960 - in /webservices/axis2/trunk/java/modules/jaxws: src/org/apache/axis2/jaxws/core/controller/ test/org/apache/axis2/jaxws/sample/
Date Fri, 03 Nov 2006 19:23:38 GMT
Author: barrettj
Date: Fri Nov  3 11:23:37 2006
New Revision: 470960

URL: http://svn.apache.org/viewvc?view=rev&rev=470960
Log:
AXIS2-1599
Contributed by Mike Rheinheimer

Modified:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/AxisInvocationController.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/InvocationController.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/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=470960&r1=470959&r2=470960
==============================================================================
--- 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
Fri Nov  3 11:23:37 2006
@@ -29,6 +29,7 @@
 import javax.xml.namespace.QName;
 import javax.xml.ws.AsyncHandler;
 import javax.xml.ws.Response;
+import javax.xml.ws.WebServiceException;
 
 import org.apache.axiom.om.OMElement;
 import org.apache.axis2.AxisFault;
@@ -51,6 +52,7 @@
 import org.apache.axis2.jaxws.i18n.Messages;
 import org.apache.axis2.jaxws.impl.AsyncListener;
 import org.apache.axis2.jaxws.impl.AsyncListenerWrapper;
+import org.apache.axis2.jaxws.marshaller.ClassUtils;
 import org.apache.axis2.jaxws.message.Message;
 import org.apache.axis2.jaxws.message.MessageException;
 import org.apache.axis2.jaxws.message.factory.MessageFactory;
@@ -156,7 +158,7 @@
      *  (non-Javadoc)
      * @see org.apache.axis2.jaxws.core.controller.InvocationController#invokeOneWay(org.apache.axis2.jaxws.core.InvocationContext)
      */
-    public void doInvokeOneWay(MessageContext request) {
+    public void doInvokeOneWay(MessageContext request) throws WebServiceException {
         // We need the qname of the operation being invoked to know which 
         // AxisOperation the OperationClient should be based on.
         // Note that the OperationDesc is only set through use of the Proxy. Dispatch
@@ -184,12 +186,13 @@
         try {
             execute(opClient, true, 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);
+            // JAXWS 6.4.2 says to throw it...
+            // Whatever exception we get here will not be from the server since a one-way
+            // invocation has no response.  This will always be a SENDER fault
+            if (log.isDebugEnabled()) {
+                log.debug("AxisFault received from client: " + af.getMessage());
+            }
+        	throw ExceptionFactory.makeWebServiceException(ClassUtils.getRootCause(af));
         }
                 
         return;

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/InvocationController.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/InvocationController.java?view=diff&rev=470960&r1=470959&r2=470960
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/InvocationController.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/InvocationController.java
Fri Nov  3 11:23:37 2006
@@ -1,203 +1,204 @@
-/*
- * Copyright 2006 The Apache Software Foundation.
- * Copyright 2006 International Business Machines Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.axis2.jaxws.core.controller;
-
-import java.util.concurrent.Future;
-
-import javax.xml.ws.AsyncHandler;
-import javax.xml.ws.Response;
-
-import org.apache.axis2.jaxws.ExceptionFactory;
-import org.apache.axis2.jaxws.core.InvocationContext;
-import org.apache.axis2.jaxws.core.MessageContext;
-import org.apache.axis2.jaxws.i18n.Messages;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * The <tt>InvocationController</tt> is an abstract implementation modeling
- * the invocation of a target web service.  All of the information that the 
- * InvocationController needs should exist within the InvocatonContext
- * that is passed in to the various invoke methods.  
- * 
- * The request information is passed in within the InvocationContext.  The
- * InvocationController assumes that there is a MessageContext within that
- * InvocationContext that is populated with all of the information that it
- * needs to invoke.  If not, an error will be returned.  Once the response 
- * comes back, the information for that response will be held inside of the
- * MessageContext representing the response, that exists in the 
- * InvocationContext.
- * 
- * The InvocationController supports four different invocation patterns:
- * 
- * 1) synchronous - This is represented by the {@link #invoke(InvocationContext)}
- * method.  This is a blocking, request/response call to the web service.
- * 
- * 2) one-way - This is represented by the {@link #invokeOneWay(InvocationContext)}
- * method.  This is a one-way invocation that only returns errors related
- * to sending the message.  If an error occurs while processing, the client
- * will not be notified.
- * 
- * 3) asynchronous (callback) - {@link #invokeAsync(InvocationContext, AsyncHandler)}
- * 
- * 4) asynchronous (polling) - {@link #invokeAsync(InvocationContext)}
- */
-public abstract class InvocationController {
-    
-    private static final Log log = LogFactory.getLog(InvocationController.class);
-    
-    /**
-     * Performs a synchronous (blocking) invocation of a target service.  The 
-     * InvocationContext passed in should contain a valid MessageContext 
-     * containing the properties and message to be sent for the request.  The
-     * response contents will be processed and placed in the InvocationContext
-     * as well.
-     * 
-     * @param ic
-     * @return
-     */
-    public InvocationContext invoke(InvocationContext ic) {
-        if (log.isDebugEnabled()) {
-            log.debug("Invocation pattern: synchronous");
-        }
-        
-        // Check to make sure we at least have a valid InvocationContext
-        // and request MessageContext
-        if (ic == null) {
-            throw ExceptionFactory.makeWebServiceException(Messages.getMessage("ICErr1"));
-        }
-        if (ic.getRequestMessageContext() == null) {
-            throw ExceptionFactory.makeWebServiceException(Messages.getMessage("ICErr2"));
-        }
-        
-        MessageContext request = ic.getRequestMessageContext();
-        MessageContext response = null;
-
-        // TODO: Place-holder for running the JAX-WS request handler chain
-        
-        prepareRequest(request);
-        
-        response = doInvoke(request);
-        prepareResponse(response);
-        ic.setResponseMessageContext(response);
-        
-        // TODO: Place-holder for running the JAX-WS response handler chain
-        
-        return ic;
-    }
-    
-    protected abstract MessageContext doInvoke(MessageContext request);
-    
-    /**
-     * Performs a one-way invocation of the client.  This is SHOULD NOT be a 
-     * robust invocation, so any fault that occurs during the processing of 
-     * the request will not be returned to the client.  Errors returned to the
-     * client are problems that occurred during the sending of the message to 
-     * the server.
-     * 
-     * @param ic
-     */
-    public void invokeOneWay(InvocationContext ic) {
-        if (log.isDebugEnabled()) {
-            log.debug("Invocation pattern: one-way");
-        }
-        
-        // Check to make sure we at least have a valid InvocationContext
-        // and request MessageContext
-        if (ic == null) {
-            throw ExceptionFactory.makeWebServiceException("ICErr1");
-        }
-        if (ic.getRequestMessageContext() == null) {
-            throw ExceptionFactory.makeWebServiceException("ICErr2");
-        }
-        
-        MessageContext request = ic.getRequestMessageContext();
-        
-        // TODO: Place-holder to run the JAX-WS request handler chain
-        
-        prepareRequest(request);
-        doInvokeOneWay(request);
-        return;
-    }
-    
-    protected abstract void doInvokeOneWay(MessageContext mc);
-    
-    /**
-     * Performs an asynchronous (non-blocking) invocation of the client based 
-     * on a callback model.  The AsyncHandler that is passed in is the callback
-     * that the client programmer supplied when they invoked their JAX-WS
-     * Dispatch or their SEI-based dynamic proxy.  
-     * 
-     * @param ic
-     * @param callback
-     * @return
-     */
-    public abstract Response invokeAsync(InvocationContext ic);
-    
-    /**
-     * Performs an asynchronous (non-blocking) invocation of the client based 
-     * on a polling model.  The Response object that is returned allows the 
-     * client programmer to poll against it to see if a response has been sent
-     * back by the server.
-     * 
-     * @param ic
-     * @return
-     */
-    public Future<?> invokeAsync(InvocationContext ic, AsyncHandler asyncHandler) {
-        if (log.isDebugEnabled()) {
-            log.debug("Invocation pattern: asynchronous(callback)");
-        }
-        
-        // Check to make sure we at least have a valid InvocationContext
-        // and request MessageContext
-        if (ic == null) {
-            throw ExceptionFactory.makeWebServiceException(Messages.getMessage("ICErr1"));
-        }
-        if (ic.getRequestMessageContext() == null) {
-            throw ExceptionFactory.makeWebServiceException(Messages.getMessage("ICErr2"));
-        }
-        
-        MessageContext request = ic.getRequestMessageContext();
-
-        // TODO: Place-holder for running the JAX-WS request handler chain
-        
-        prepareRequest(request);
-        Future<?> future = doInvokeAsync(request, asyncHandler);
-        return future;        
-    }
-    
-    public abstract Future<?> doInvokeAsync(MessageContext mc, AsyncHandler asyncHandler);
-    
-    /**
-     * Abstract method that must be implemented by whoever is providing
-     * the specific client binding.  Once this is called, everything that
-     * is needed to invoke the operation must be available in the 
-     * MessageContext.
-     * @param mc
-     */
-    protected abstract void prepareRequest(MessageContext mc);
-    
-    /**
-     * Abstract method that must be implemented by whoever is providing
-     * the specific client binding.  This is called after the response has 
-     * come back and allows the client binding to put whatever info it has
-     * in the response MessageContext.
-     * @param mc
-     */
-    protected abstract void prepareResponse(MessageContext mc);
-    
-}
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.jaxws.core.controller;
+
+import java.util.concurrent.Future;
+
+import javax.xml.ws.AsyncHandler;
+import javax.xml.ws.Response;
+import javax.xml.ws.WebServiceException;
+
+import org.apache.axis2.jaxws.ExceptionFactory;
+import org.apache.axis2.jaxws.core.InvocationContext;
+import org.apache.axis2.jaxws.core.MessageContext;
+import org.apache.axis2.jaxws.i18n.Messages;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * The <tt>InvocationController</tt> is an abstract implementation modeling
+ * the invocation of a target web service.  All of the information that the 
+ * InvocationController needs should exist within the InvocatonContext
+ * that is passed in to the various invoke methods.  
+ * 
+ * The request information is passed in within the InvocationContext.  The
+ * InvocationController assumes that there is a MessageContext within that
+ * InvocationContext that is populated with all of the information that it
+ * needs to invoke.  If not, an error will be returned.  Once the response 
+ * comes back, the information for that response will be held inside of the
+ * MessageContext representing the response, that exists in the 
+ * InvocationContext.
+ * 
+ * The InvocationController supports four different invocation patterns:
+ * 
+ * 1) synchronous - This is represented by the {@link #invoke(InvocationContext)}
+ * method.  This is a blocking, request/response call to the web service.
+ * 
+ * 2) one-way - This is represented by the {@link #invokeOneWay(InvocationContext)}
+ * method.  This is a one-way invocation that only returns errors related
+ * to sending the message.  If an error occurs while processing, the client
+ * will not be notified.
+ * 
+ * 3) asynchronous (callback) - {@link #invokeAsync(InvocationContext, AsyncHandler)}
+ * 
+ * 4) asynchronous (polling) - {@link #invokeAsync(InvocationContext)}
+ */
+public abstract class InvocationController {
+    
+    private static final Log log = LogFactory.getLog(InvocationController.class);
+    
+    /**
+     * Performs a synchronous (blocking) invocation of a target service.  The 
+     * InvocationContext passed in should contain a valid MessageContext 
+     * containing the properties and message to be sent for the request.  The
+     * response contents will be processed and placed in the InvocationContext
+     * as well.
+     * 
+     * @param ic
+     * @return
+     */
+    public InvocationContext invoke(InvocationContext ic) {
+        if (log.isDebugEnabled()) {
+            log.debug("Invocation pattern: synchronous");
+        }
+        
+        // Check to make sure we at least have a valid InvocationContext
+        // and request MessageContext
+        if (ic == null) {
+            throw ExceptionFactory.makeWebServiceException(Messages.getMessage("ICErr1"));
+        }
+        if (ic.getRequestMessageContext() == null) {
+            throw ExceptionFactory.makeWebServiceException(Messages.getMessage("ICErr2"));
+        }
+        
+        MessageContext request = ic.getRequestMessageContext();
+        MessageContext response = null;
+
+        // TODO: Place-holder for running the JAX-WS request handler chain
+        
+        prepareRequest(request);
+        
+        response = doInvoke(request);
+        prepareResponse(response);
+        ic.setResponseMessageContext(response);
+        
+        // TODO: Place-holder for running the JAX-WS response handler chain
+        
+        return ic;
+    }
+    
+    protected abstract MessageContext doInvoke(MessageContext request);
+    
+    /**
+     * Performs a one-way invocation of the client.  This is SHOULD NOT be a 
+     * robust invocation, so any fault that occurs during the processing of 
+     * the request will not be returned to the client.  Errors returned to the
+     * client are problems that occurred during the sending of the message to 
+     * the server.
+     * 
+     * @param ic
+     */
+    public void invokeOneWay(InvocationContext ic) {
+        if (log.isDebugEnabled()) {
+            log.debug("Invocation pattern: one-way");
+        }
+        
+        // Check to make sure we at least have a valid InvocationContext
+        // and request MessageContext
+        if (ic == null) {
+            throw ExceptionFactory.makeWebServiceException("ICErr1");
+        }
+        if (ic.getRequestMessageContext() == null) {
+            throw ExceptionFactory.makeWebServiceException("ICErr2");
+        }
+        
+        MessageContext request = ic.getRequestMessageContext();
+        
+        // TODO: Place-holder to run the JAX-WS request handler chain
+        
+        prepareRequest(request);
+        doInvokeOneWay(request);
+        return;
+    }
+    
+    protected abstract void doInvokeOneWay(MessageContext mc) throws WebServiceException;
+    
+    /**
+     * Performs an asynchronous (non-blocking) invocation of the client based 
+     * on a callback model.  The AsyncHandler that is passed in is the callback
+     * that the client programmer supplied when they invoked their JAX-WS
+     * Dispatch or their SEI-based dynamic proxy.  
+     * 
+     * @param ic
+     * @param callback
+     * @return
+     */
+    public abstract Response invokeAsync(InvocationContext ic);
+    
+    /**
+     * Performs an asynchronous (non-blocking) invocation of the client based 
+     * on a polling model.  The Response object that is returned allows the 
+     * client programmer to poll against it to see if a response has been sent
+     * back by the server.
+     * 
+     * @param ic
+     * @return
+     */
+    public Future<?> invokeAsync(InvocationContext ic, AsyncHandler asyncHandler) {
+        if (log.isDebugEnabled()) {
+            log.debug("Invocation pattern: asynchronous(callback)");
+        }
+        
+        // Check to make sure we at least have a valid InvocationContext
+        // and request MessageContext
+        if (ic == null) {
+            throw ExceptionFactory.makeWebServiceException(Messages.getMessage("ICErr1"));
+        }
+        if (ic.getRequestMessageContext() == null) {
+            throw ExceptionFactory.makeWebServiceException(Messages.getMessage("ICErr2"));
+        }
+        
+        MessageContext request = ic.getRequestMessageContext();
+
+        // TODO: Place-holder for running the JAX-WS request handler chain
+        
+        prepareRequest(request);
+        Future<?> future = doInvokeAsync(request, asyncHandler);
+        return future;        
+    }
+    
+    public abstract Future<?> doInvokeAsync(MessageContext mc, AsyncHandler asyncHandler);
+    
+    /**
+     * Abstract method that must be implemented by whoever is providing
+     * the specific client binding.  Once this is called, everything that
+     * is needed to invoke the operation must be available in the 
+     * MessageContext.
+     * @param mc
+     */
+    protected abstract void prepareRequest(MessageContext mc);
+    
+    /**
+     * Abstract method that must be implemented by whoever is providing
+     * the specific client binding.  This is called after the response has 
+     * come back and allows the client binding to put whatever info it has
+     * in the response MessageContext.
+     * @param mc
+     */
+    protected abstract void prepareResponse(MessageContext mc);
+    
+}

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=470960&r1=470959&r2=470960
==============================================================================
--- 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
Fri Nov  3 11:23:37 2006
@@ -13,6 +13,8 @@
 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;
 
 
 public class FaultyWebServiceTests extends TestCase {
@@ -78,4 +80,40 @@
         assertEquals(exception.getMessage(), host);
 
     }
+
+    // TODO should also have an invoke oneway bad endpoint test to make sure
+    // we get an exception as indicated in JAXWS 6.4.2.
+
+    
+    public void testFaultyWebService_badEndpoint_oneWay() {
+        
+        String host = "this.is.a.bad.endpoint.terrible.in.fact";
+        String badEndpoint = "http://" + host;
+        
+        WebServiceException exception = null;
+        
+        System.out.println("------------------------------");
+        System.out.println("Test : "+getName());
+        try{
+            
+            DocLitWrapService service = new DocLitWrapService();
+            DocLitWrap proxy = service.getDocLitWrapPort();
+            BindingProvider p = (BindingProvider)proxy;
+            p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,badEndpoint);
+            proxy.oneWayVoid();
+            
+        }catch(WebServiceException e) {
+            exception = e;
+        }catch(Exception e) {
+            fail("This testcase should only produce a WebServiceException.  We got: " + e.toString());
+        }
+        
+        System.out.println("----------------------------------");
+        
+        assertNotNull(exception);
+        assertTrue(exception.getCause() instanceof UnknownHostException);
+        assertEquals(exception.getMessage(), host);
+        
+    }
+    
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message