cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r658433 - in /cxf/trunk: rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/ rt/frontend/simple/src/main/java/org/...
Date Tue, 20 May 2008 21:08:05 GMT
Author: dkulp
Date: Tue May 20 14:08:04 2008
New Revision: 658433

URL: http://svn.apache.org/viewvc?rev=658433&view=rev
Log:
[CXF-1575, CXF-1592] Don't map webServiceException into the wsdl.  In some cases, allow an
older saaj implementation.

Modified:
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
    cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBeanTest.java
    cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/aegis/AegisClientServerTest.java

Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java?rev=658433&r1=658432&r2=658433&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java (original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java Tue
May 20 14:08:04 2008
@@ -31,6 +31,7 @@
 import java.util.logging.Logger;
 
 import javax.xml.namespace.QName;
+import javax.xml.soap.SOAPException;
 import javax.xml.soap.SOAPFault;
 import javax.xml.ws.AsyncHandler;
 import javax.xml.ws.Binding;
@@ -190,31 +191,11 @@
                 exception.initCause(ex);
                 throw exception;
             } else if (getBinding() instanceof SOAPBinding) {
-                SOAPFault soapFault = ((SOAPBinding)getBinding()).getSOAPFactory().createFault();
+                SOAPFault soapFault = createSoapFault(ex);
+                if (soapFault == null) {
+                    throw new WebServiceException(ex);
+                }
                 
-                if (ex instanceof SoapFault) {
-                    soapFault.setFaultString(((SoapFault)ex).getReason());
-                    soapFault.setFaultCode(((SoapFault)ex).getFaultCode());
-                    soapFault.setFaultActor(((SoapFault)ex).getRole());
-
-                    Node nd = soapFault.getOwnerDocument().importNode(((SoapFault)ex).getOrCreateDetail(),
-                                                                      true);
-                    nd = nd.getFirstChild();
-                    soapFault.addDetail();
-                    while (nd != null) {
-                        Node next = nd.getNextSibling();
-                        soapFault.getDetail().appendChild(nd);
-                        nd = next;
-                    }
- 
-                } else {
-                    soapFault.setFaultCode(new QName("http://cxf.apache.org/faultcode", "HandlerFault"));
-                    String msg = ex.getMessage();
-                    if (msg != null) {
-                        soapFault.setFaultString(msg);
-                    }
-                }      
-  
                 SOAPFaultException  exception = new SOAPFaultException(soapFault);
                 exception.initCause(ex);
                 throw exception;                
@@ -241,6 +222,47 @@
 
     }
     
+    private SOAPFault createSoapFault(Exception ex) throws SOAPException {
+        SOAPFault soapFault;
+        try {
+            soapFault = ((SOAPBinding)getBinding()).getSOAPFactory().createFault();
+        } catch (Throwable t) {
+            //probably an old version of saaj or something that is not allowing createFault

+            //method to work.  Try the saaj 1.2 method of doing this.
+            try {
+                soapFault = ((SOAPBinding)getBinding()).getMessageFactory().createMessage()
+                    .getSOAPBody().addFault();
+            } catch (Throwable t2) {
+                //still didn't work, we'll just throw what we have
+                return null;
+            }                        
+        }
+        
+        if (ex instanceof SoapFault) {
+            soapFault.setFaultString(((SoapFault)ex).getReason());
+            soapFault.setFaultCode(((SoapFault)ex).getFaultCode());
+            soapFault.setFaultActor(((SoapFault)ex).getRole());
+
+            Node nd = soapFault.getOwnerDocument().importNode(((SoapFault)ex).getOrCreateDetail(),
+                                                              true);
+            nd = nd.getFirstChild();
+            soapFault.addDetail();
+            while (nd != null) {
+                Node next = nd.getNextSibling();
+                soapFault.getDetail().appendChild(nd);
+                nd = next;
+            }
+
+        } else {
+            soapFault.setFaultCode(new QName("http://cxf.apache.org/faultcode", "HandlerFault"));
+            String msg = ex.getMessage();
+            if (msg != null) {
+                soapFault.setFaultString(msg);
+            }
+        }      
+        return soapFault;
+    }
+
     private boolean addressChanged(String address) {
         return !(address == null
                  || getClient().getEndpoint().getEndpointInfo() == null

Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java?rev=658433&r1=658432&r2=658433&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
(original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
Tue May 20 14:08:04 2008
@@ -350,7 +350,8 @@
     protected Class<?> getBeanClass(Class<?> exClass) {
         try {
             if (java.rmi.ServerException.class.isAssignableFrom(exClass)
-                || java.rmi.RemoteException.class.isAssignableFrom(exClass)) {
+                || java.rmi.RemoteException.class.isAssignableFrom(exClass)
+                || "javax.xml.ws".equals(exClass.getPackage().getName())) {
                 return null;
             }
 

Modified: cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBeanTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBeanTest.java?rev=658433&r1=658432&r2=658433&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBeanTest.java
(original)
+++ cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBeanTest.java
Tue May 20 14:08:04 2008
@@ -24,10 +24,13 @@
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
+
+import javax.jws.WebService;
 import javax.wsdl.Definition;
 import javax.wsdl.factory.WSDLFactory;
 import javax.xml.namespace.QName;
 import javax.xml.ws.Binding;
+import javax.xml.ws.WebServiceException;
 import javax.xml.ws.WebServiceFeature;
 import javax.xml.ws.soap.MTOMFeature;
 import javax.xml.ws.soap.SOAPBinding;
@@ -254,4 +257,28 @@
         assertTrue(binding instanceof SOAPBinding);
         assertTrue(((SOAPBinding)binding).isMTOMEnabled());
     }   
+    
+    @Test
+    public void testWebSeviceException() throws Exception {
+        ReflectionServiceFactoryBean bean = new JaxWsServiceFactoryBean();
+        Bus bus = getBus();
+        bean.setBus(bus);
+        bean.setServiceClass(WebServiceExceptionTestImpl.class);
+        Service service = bean.create();
+        ServiceInfo si = service.getServiceInfos().get(0);
+        ServiceWSDLBuilder builder = new ServiceWSDLBuilder(bus, si);
+        Definition def = builder.build();
+        
+        Document wsdl = WSDLFactory.newInstance().newWSDLWriter().getDocument(def);
+        
+        assertInvalid("/wsdl:definitions/wsdl:message[@name='WebServiceException']", wsdl);
+    }
+    
+    @WebService
+    public static class WebServiceExceptionTestImpl {
+        public int echoInt(int i) throws WebServiceException {
+            return i;
+        }
+        
+    }
 }

Modified: cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java?rev=658433&r1=658432&r2=658433&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
(original)
+++ cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
Tue May 20 14:08:04 2008
@@ -680,6 +680,9 @@
         for (int i = 0; i < types.length; i++) {
             Class exClass = types[i];
             Class beanClass = getBeanClass(exClass);
+            if (beanClass == null) {
+                continue;
+            }
 
             QName name = getFaultName(o.getInterface(), o, exClass, beanClass);
 

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/aegis/AegisClientServerTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/aegis/AegisClientServerTest.java?rev=658433&r1=658432&r2=658433&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/aegis/AegisClientServerTest.java
(original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/aegis/AegisClientServerTest.java
Tue May 20 14:08:04 2008
@@ -40,7 +40,6 @@
 import org.apache.cxf.test.TestUtilities;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.junit.BeforeClass;
-import org.junit.Ignore;
 import org.junit.Test;
 
 public class AegisClientServerTest extends AbstractBusClientServerTestBase {
@@ -156,12 +155,11 @@
         assertEquals("Anullb", s);        
     }
     
-    @Ignore
     @Test
     public void testDynamicClient() throws Exception {
         DynamicClientFactory dcf = DynamicClientFactory.newInstance();
         Client client = dcf.createClient("http://localhost:9002/jaxwsAndAegisSports?wsdl");
-        Object r = client.invoke("getAttributeBean", (Object[]) null);
+        Object r = client.invoke("getAttributeBean")[0];
         Method getAddrPlainString = r.getClass().getMethod("getAttrPlainString");
         String s = (String)getAddrPlainString.invoke(r);
         assertEquals("attrPlain", s);



Mime
View raw message