cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r570852 - in /incubator/cxf/trunk: rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/ systests/src/test/java/org/apache/cxf/systest/jaxws/ tools/common/src/main/java/org/apache/cxf/tools/util/
Date Wed, 29 Aug 2007 16:19:39 GMT
Author: dkulp
Date: Wed Aug 29 09:19:36 2007
New Revision: 570852

URL: http://svn.apache.org/viewvc?rev=570852&view=rev
Log:
[CXF-899] Apply patch for not requiring FaultInfo at runtime
Add test case for basic auth on Conduit directly
Fix potential NPE in tooling

Modified:
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WebFaultOutInterceptor.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java
    incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/SOAPBindingUtil.java

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WebFaultOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WebFaultOutInterceptor.java?rev=570852&r1=570851&r2=570852&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WebFaultOutInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WebFaultOutInterceptor.java
Wed Aug 29 09:19:36 2007
@@ -22,6 +22,7 @@
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.ResourceBundle;
+import java.util.logging.Logger;
 
 import javax.xml.namespace.QName;
 import javax.xml.ws.WebFault;
@@ -29,6 +30,7 @@
 import org.w3c.dom.Node;
 
 import org.apache.cxf.common.i18n.BundleUtils;
+import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.databinding.DataWriter;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.jaxws.support.JaxWsServiceConfiguration;
@@ -42,6 +44,8 @@
 import org.apache.cxf.service.model.OperationInfo;
 
 public class WebFaultOutInterceptor extends AbstractPhaseInterceptor<Message> {
+
+    private static final Logger LOG = LogUtils.getL7dLogger(WebFaultOutInterceptor.class);
     private static final ResourceBundle BUNDLE = BundleUtils.getBundle(JaxWsServiceConfiguration.class);
 
     public WebFaultOutInterceptor() {
@@ -73,29 +77,32 @@
         }
         if (cause instanceof Exception && fault != null) {
             Exception ex = (Exception)cause;
+            Object faultInfo = null;
             try {
                 Method method = cause.getClass().getMethod("getFaultInfo", new Class[0]);
-                Object faultInfo = method.invoke(cause, new Object[0]);
-
-                Service service = message.getExchange().get(Service.class);
-
-                DataWriter<Node> writer = service.getDataBinding().createWriter(Node.class);
-
-                OperationInfo op = message.getExchange().get(BindingOperationInfo.class).getOperationInfo();
-                QName faultName = getFaultName(fault);
-                MessagePartInfo part = getFaultMessagePart(faultName, op);
-                writer.write(faultInfo, part, f.getOrCreateDetail());
-
-                f.setMessage(ex.getMessage());
+                faultInfo = method.invoke(cause, new Object[0]);
+            } catch (NoSuchMethodException e) {
+                faultInfo = cause;
+                LOG.fine("Using @WebFault annotated class "
+                        + faultInfo.getClass().getName() 
+                        + " as faultInfo since getFaultInfo() was not found");
             } catch (InvocationTargetException e) {
                 throw new Fault(new org.apache.cxf.common.i18n.Message("INVOCATION_TARGET_EXC",
BUNDLE), e);
-            } catch (NoSuchMethodException e) {
-                throw new Fault(new org.apache.cxf.common.i18n.Message("NO_GETFAULTINFO_METHOD",
BUNDLE), e);
-            } catch (IllegalArgumentException e) {
-                throw new Fault(new org.apache.cxf.common.i18n.Message("COULD_NOT_INVOKE",
BUNDLE), e);
             } catch (IllegalAccessException e) {
                 throw new Fault(new org.apache.cxf.common.i18n.Message("COULD_NOT_INVOKE",
BUNDLE), e);
+            } catch (IllegalArgumentException e) {
+                throw new Fault(new org.apache.cxf.common.i18n.Message("COULD_NOT_INVOKE",
BUNDLE), e);
             }
+            Service service = message.getExchange().get(Service.class);
+
+            DataWriter<Node> writer = service.getDataBinding().createWriter(Node.class);
+
+            OperationInfo op = message.getExchange().get(BindingOperationInfo.class).getOperationInfo();
+            QName faultName = getFaultName(fault);
+            MessagePartInfo part = getFaultMessagePart(faultName, op);
+            writer.write(faultInfo, part, f.getOrCreateDetail());
+
+            f.setMessage(ex.getMessage());
         }
     }
 

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java?rev=570852&r1=570851&r2=570852&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java
Wed Aug 29 09:19:36 2007
@@ -53,12 +53,15 @@
 
 //import org.apache.cxf.Bus;
 import org.apache.cxf.binding.soap.Soap11;
+import org.apache.cxf.configuration.security.AuthorizationPolicy;
 import org.apache.cxf.endpoint.Client;
 import org.apache.cxf.endpoint.dynamic.DynamicClientFactory;
+import org.apache.cxf.frontend.ClientProxy;
 import org.apache.cxf.helpers.XMLUtils;
 import org.apache.cxf.helpers.XPathUtils;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.apache.cxf.transport.http.HTTPConduit;
 import org.apache.hello_world_soap_http.BadRecordLitFault;
 import org.apache.hello_world_soap_http.DocLitBare;
 import org.apache.hello_world_soap_http.Greeter;
@@ -766,11 +769,25 @@
         Greeter greeter = service.getPort(fakePortName, Greeter.class);
 
         try {
+            //try the jaxws way
             BindingProvider bp = (BindingProvider)greeter;
             bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "BJ");
             bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "pswd");
             String s = greeter.greetMe("secure");
             assertEquals("Hello BJ", s);
+            bp.getRequestContext().remove(BindingProvider.USERNAME_PROPERTY);
+            bp.getRequestContext().remove(BindingProvider.PASSWORD_PROPERTY);
+            
+            //try setting on the conduit directly
+            Client client = ClientProxy.getClient(greeter);
+            HTTPConduit httpConduit = (HTTPConduit)client.getConduit();
+            AuthorizationPolicy policy = new AuthorizationPolicy();
+            policy.setUserName("BJ2");
+            policy.setPassword("pswd");
+            httpConduit.setAuthorization(policy);
+            
+            s = greeter.greetMe("secure");
+            assertEquals("Hello BJ2", s);
         } catch (UndeclaredThrowableException ex) {
             throw (Exception)ex.getCause();
         }

Modified: incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/SOAPBindingUtil.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/SOAPBindingUtil.java?rev=570852&r1=570851&r2=570852&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/SOAPBindingUtil.java
(original)
+++ incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/SOAPBindingUtil.java
Wed Aug 29 09:19:36 2007
@@ -171,9 +171,11 @@
     }
 
     public static SoapBody getSoapBody(List<ExtensibilityElement> exts) {
-        for (ExtensibilityElement ext : exts) {
-            if (isSOAPBody(ext)) {
-                return getSoapBody(ext);
+        if (exts != null) {
+            for (ExtensibilityElement ext : exts) {
+                if (isSOAPBody(ext)) {
+                    return getSoapBody(ext);
+                }
             }
         }
         return null;
@@ -196,9 +198,11 @@
 
     public static List<SoapHeader> getSoapHeaders(List<ExtensibilityElement>
exts) {
         List<SoapHeader> headers = new ArrayList<SoapHeader>();
-        for (ExtensibilityElement ext : exts) {
-            if (isSOAPHeader(ext)) {
-                headers.add(getSoapHeader(ext));
+        if (exts != null) {
+            for (ExtensibilityElement ext : exts) {
+                if (isSOAPHeader(ext)) {
+                    headers.add(getSoapHeader(ext));
+                }
             }
         }
         return headers;



Mime
View raw message