axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ngalla...@apache.org
Subject svn commit: r502367 - /webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/ProviderDispatcher.java
Date Thu, 01 Feb 2007 21:40:27 GMT
Author: ngallardo
Date: Thu Feb  1 13:40:26 2007
New Revision: 502367

URL: http://svn.apache.org/viewvc?view=rev&rev=502367
Log:
AXIS2-2079

- Fixed the ProviderDispatcher to handle fault MessageContexts correctly as well.

Modified:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/ProviderDispatcher.java

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/ProviderDispatcher.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/ProviderDispatcher.java?view=diff&rev=502367&r1=502366&r2=502367
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/ProviderDispatcher.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/ProviderDispatcher.java
Thu Feb  1 13:40:26 2007
@@ -42,8 +42,6 @@
 import org.apache.axis2.jaxws.message.Message;
 import org.apache.axis2.jaxws.message.Protocol;
 import org.apache.axis2.jaxws.message.XMLFault;
-import org.apache.axis2.jaxws.message.XMLFaultCode;
-import org.apache.axis2.jaxws.message.XMLFaultReason;
 import org.apache.axis2.jaxws.message.factory.BlockFactory;
 import org.apache.axis2.jaxws.message.factory.MessageFactory;
 import org.apache.axis2.jaxws.message.factory.SOAPEnvelopeBlockFactory;
@@ -88,6 +86,7 @@
 	public ProviderDispatcher(Class _class, Object serviceInstance) {
 		super(_class, serviceInstance);
 	}
+    
     /* (non-Javadoc)
      * @see org.apache.axis2.jaxws.server.EndpointDispatcher#execute()
      */
@@ -171,6 +170,8 @@
         }
 
         // Invoke the actual Provider.invoke() method
+        boolean faultThrown = false;
+        XMLFault fault = null;
         Object responseParamValue = null;
         try {
             responseParamValue = (Object) org.apache.axis2.java.security.AccessController.doPrivileged(new
PrivilegedAction() {
@@ -180,33 +181,45 @@
             });
         } catch (Exception e) {
             Throwable t = ClassUtils.getRootCause(e);
+            faultThrown = true;
+            fault = MethodMarshallerUtils.createXMLFaultFromSystemException(t);
+            
             if (log.isDebugEnabled()) {
                 log.debug("Marshal Throwable =" + e.getClass().getName());
                 log.debug("  rootCause =" + t.getClass().getName());
                 log.debug("  exception=" + t.toString());
             }
-            responseParamValue =MethodMarshallerUtils.createXMLFaultFromSystemException(t);
         }
 
-        // If we have a one-way operation, then we cannot create a MessageContext 
-        // for the response.  
+        // Create the response MessageContext
         MessageContext responseMsgCtx = null;
         if (!isOneWay(mc.getAxisMessageContext())) {
-            Message responseMsg = createMessageFromValue(responseParamValue);
-            
-            // Enable MTOM if indicated by the binding
-            String bindingType = endpointDesc.getBindingType();
-            if (bindingType != null) {
-                if (bindingType.equals(SOAPBinding.SOAP11HTTP_MTOM_BINDING) ||
-                    bindingType.equals(SOAPBinding.SOAP12HTTP_MTOM_BINDING)) {
-                    responseMsg.setMTOMEnabled(true);
+            if (faultThrown) {
+                // If a fault was thrown, we need to create a slightly different
+                // MessageContext, than in the response path.
+                Message responseMsg = createMessageFromValue(fault);
+                responseMsgCtx = MessageContextUtils.createFaultMessageContext(mc);
+                responseMsgCtx.setMessage(responseMsg);
+            }
+            else {
+                Message responseMsg = createMessageFromValue(responseParamValue);
+                
+                // Enable MTOM if indicated by the binding
+                String bindingType = endpointDesc.getBindingType();
+                if (bindingType != null) {
+                    if (bindingType.equals(SOAPBinding.SOAP11HTTP_MTOM_BINDING) ||
+                        bindingType.equals(SOAPBinding.SOAP12HTTP_MTOM_BINDING)) {
+                        responseMsg.setMTOMEnabled(true);
+                    }
                 }
+                
+                responseMsgCtx = MessageContextUtils.createResponseMessageContext(mc);
+                responseMsgCtx.setMessage(responseMsg);                
             }
-            
-            responseMsgCtx = MessageContextUtils.
-                createResponseMessageContext(mc);
-            
-            responseMsgCtx.setMessage(responseMsg);            
+        }
+        else {
+            // If we have a one-way operation, then we cannot create a MessageContext for
the response.
+            return null;
         }
                 
         return responseMsgCtx;        
@@ -339,12 +352,14 @@
     		try{
     			paramType = (ParameterizedType)giType;
     		}catch(ClassCastException e){
+                //TODO NLS
     			throw new Exception("Provider based SEI Class has to implement javax.xml.ws.Provider
as javax.xml.ws.Provider<String>, javax.xml.ws.Provider<SOAPMessage>, javax.xml.ws.Provider<Source>
or javax.xml.ws.Provider<JAXBContext>");
     		}
     		Class interfaceName = (Class)paramType.getRawType();
     		
     		if(interfaceName == javax.xml.ws.Provider.class){
     			if(paramType.getActualTypeArguments().length > 1){
+                    //TODO NLS
     				throw new Exception("Provider cannot have more than one Generic Types defined as
Per JAX-WS Specification");
     			}
     			providerType = (Class)paramType.getActualTypeArguments()[0];



---------------------------------------------------------------------
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