cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject svn commit: r601261 - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/ws/addressing/ rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/ systests/src/test/java/org/apache/cxf/sy...
Date Wed, 05 Dec 2007 09:13:17 GMT
Author: mmao
Date: Wed Dec  5 01:13:14 2007
New Revision: 601261

URL: http://svn.apache.org/viewvc?rev=601261&view=rev
Log:
CXF-1241
 WS-A Action/FaultAction support From Java approach


Modified:
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/addressing/JAXWSAConstants.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
    incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromjava/WSAFromJavaTest.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromjava/server/Server.java
    incubator/cxf/trunk/systests/src/test/resources/wsdl/add_numbers-fromjava.wsdl

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/addressing/JAXWSAConstants.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/addressing/JAXWSAConstants.java?rev=601261&r1=601260&r2=601261&view=diff
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/addressing/JAXWSAConstants.java
(original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/addressing/JAXWSAConstants.java
Wed Dec  5 01:13:14 2007
@@ -20,11 +20,16 @@
 
 package org.apache.cxf.ws.addressing;
 
+import javax.xml.namespace.QName;
+
 
 /**
  * A container for WS-Addressing constants.
  */
 public final class JAXWSAConstants {
+
+    public static final QName WSAW_ACTION_QNAME = new QName("http://www.w3.org/2006/05/addressing/wsdl",

+                                                            "Action");
 
     /**
      * Well-known Property names for AddressingProperties in BindingProvider

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java?rev=601261&r1=601260&r2=601261&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
Wed Dec  5 01:13:14 2007
@@ -28,7 +28,9 @@
 import java.util.logging.Logger;
 import javax.wsdl.Operation;
 import javax.xml.namespace.QName;
+import javax.xml.ws.Action;
 import javax.xml.ws.AsyncHandler;
+import javax.xml.ws.FaultAction;
 import javax.xml.ws.Service;
 import javax.xml.ws.Service.Mode;
 import javax.xml.ws.WebFault;
@@ -60,6 +62,8 @@
 import org.apache.cxf.service.model.MessageInfo;
 import org.apache.cxf.service.model.MessagePartInfo;
 import org.apache.cxf.service.model.OperationInfo;
+import org.apache.cxf.service.model.ServiceInfo;
+import org.apache.cxf.ws.addressing.JAXWSAConstants;
 import org.apache.cxf.wsdl11.WSDLServiceBuilder;
 
 /**
@@ -467,5 +471,50 @@
 
     public void setWsFeatures(List<WebServiceFeature> wsFeatures) {
         this.wsFeatures = wsFeatures;
+    }
+
+    private FaultInfo getFaultInfo(final OperationInfo operation, final Class expClass) {
+        for (FaultInfo fault : operation.getFaults()) {
+            if (fault.getProperty(Class.class.getName()) == expClass) {
+                return fault;
+            }
+        }
+        return null;
+    }
+    
+    private void buildWSAActions(OperationInfo operation, Method method) {
+        Action action = method.getAnnotation(Action.class);
+        if (action == null) {
+            return;
+        }
+        String ns = operation.getName().getNamespaceURI();
+        MessageInfo input = operation.getInput();
+        if (action.input() != null) {
+            input.addExtensionAttribute(JAXWSAConstants.WSAW_ACTION_QNAME, new QName(ns,
action.input()));
+        }
+        
+        MessageInfo output = operation.getOutput();
+        if (output != null && action.output() != null) {
+            output.addExtensionAttribute(JAXWSAConstants.WSAW_ACTION_QNAME, new QName(ns,
action.output()));
+        }
+        
+        FaultAction[] faultActions = action.fault();
+        if (faultActions != null && operation.getFaults() != null) {
+            for (FaultAction faultAction : faultActions) {                
+                FaultInfo faultInfo = getFaultInfo(operation, faultAction.className());
+                faultInfo.addExtensionAttribute(JAXWSAConstants.WSAW_ACTION_QNAME, 
+                                                new QName(ns, faultAction.value()));
+            }
+        }        
+    }
+    
+    @Override
+    protected OperationInfo createOperation(ServiceInfo serviceInfo, InterfaceInfo intf,
Method m) {
+        OperationInfo op = super.createOperation(serviceInfo, intf, m);
+        if (op.getUnwrappedOperation() != null) {
+            op = op.getUnwrappedOperation();
+        }
+        buildWSAActions(op, m);
+        return op;
     }
 }

Modified: incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java?rev=601261&r1=601260&r2=601261&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java
(original)
+++ incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java
Wed Dec  5 01:13:14 2007
@@ -62,8 +62,6 @@
         LogUtils.getL7dLogger(MAPAggregator.class);
     private static final ResourceBundle BUNDLE = LOG.getResourceBundle();
 
-    private static final QName WSAW_ACTION_QNAME = new QName("http://www.w3.org/2006/05/addressing/wsdl",

-                                                             "Action");
     
 
     /**
@@ -400,7 +398,7 @@
         MessageInfo inputMessage = operation.getInput();
 
         if (inputMessage.getExtensionAttributes() != null) {
-            QName inputAction = (QName)inputMessage.getExtensionAttribute(WSAW_ACTION_QNAME);
+            QName inputAction = (QName)inputMessage.getExtensionAttribute(JAXWSAConstants.WSAW_ACTION_QNAME);
             if (inputAction != null) {
                 return inputAction.getLocalPart();
             }
@@ -411,7 +409,8 @@
     private String getActionFromOutputMessage(final OperationInfo operation) {
         MessageInfo outputMessage = operation.getOutput();
         if (outputMessage != null && outputMessage.getExtensionAttributes() != null)
{
-            QName outputAction = (QName)outputMessage.getExtensionAttribute(WSAW_ACTION_QNAME);
+            QName outputAction = 
+                (QName)outputMessage.getExtensionAttribute(JAXWSAConstants.WSAW_ACTION_QNAME);
             if (outputAction != null) {
                 return outputAction.getLocalPart();
             }
@@ -438,7 +437,8 @@
             for (FaultInfo faultInfo : operation.getFaults()) {
                 if (isSameFault(faultInfo, faultName)) {
                     if (faultInfo.getExtensionAttributes() != null) {
-                        QName faultAction = (QName)faultInfo.getExtensionAttribute(WSAW_ACTION_QNAME);
+                        QName faultAction = 
+                            (QName)faultInfo.getExtensionAttribute(JAXWSAConstants.WSAW_ACTION_QNAME);
                         return faultAction.getLocalPart();
                     }
                     return addPath(addPath(getActionBaseUri(operation), "Fault"), 
@@ -446,7 +446,7 @@
                 }
             }
         }
-        return null;
+        return addPath(addPath(getActionBaseUri(operation), "Fault"), faultName);
     }
 
     private String getFaultNameFromMessage(final Message message) {
@@ -457,7 +457,7 @@
                 return t.name();
             }
         }
-        return null;    
+        return e.getCause().getClass().getSimpleName();    
     }
 
     protected String getActionUri(Message message) {

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromjava/WSAFromJavaTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromjava/WSAFromJavaTest.java?rev=601261&r1=601260&r2=601261&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromjava/WSAFromJavaTest.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromjava/WSAFromJavaTest.java
Wed Dec  5 01:13:14 2007
@@ -28,6 +28,7 @@
 import org.apache.cxf.interceptor.LoggingOutInterceptor;
 import org.apache.cxf.systest.ws.addr_fromjava.client.AddNumberImpl;
 import org.apache.cxf.systest.ws.addr_fromjava.client.AddNumberImplService;
+import org.apache.cxf.systest.ws.addr_fromjava.client.AddNumbersException_Exception;
 import org.apache.cxf.systest.ws.addr_fromjava.server.Server;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.junit.Before;
@@ -76,9 +77,67 @@
         String expectedOut = "http://cxf.apache.org/input";
         assertTrue(output.toString().indexOf(expectedOut) != -1);
         
-        // TODO: will support response action after the java2wsdl support the wsa:action
         String expectedIn = "http://cxf.apache.org/output";
-        assertTrue(input.toString().indexOf(expectedIn) == -1);
+        assertTrue(input.toString().indexOf(expectedIn) != -1);
+    }
+
+    @Test
+    public void testAddNumbersFault() {
+        ByteArrayOutputStream input = setupInLogging();
+        ByteArrayOutputStream output = setupOutLogging();
+
+        AddNumberImpl port = getPort();
+
+        try {
+            port.addNumbers(-1, 2);
+        } catch (AddNumbersException_Exception e) {
+            assert true;
+        } catch (Exception e) {
+            e.printStackTrace();
+            assert false;
+        }
+
+        assertTrue(output.toString().indexOf("http://cxf.apache.org/input") != -1);
+        String expectedFault = 
+            "http://server.addr_fromjava.ws.systest.cxf.apache.org/AddNumberImpl/Fault/AddNumbersException";
+        assertTrue(input.toString().indexOf(expectedFault) != -1);
+    }
+
+    @Test
+    public void testAddNumbers2() throws Exception {
+        ByteArrayOutputStream input = setupInLogging();
+        ByteArrayOutputStream output = setupOutLogging();
+
+        AddNumberImpl port = getPort();
+
+        assertEquals(3, port.addNumbers2(1, 2));
+        
+        String base = "http://server.addr_fromjava.ws.systest.cxf.apache.org/AddNumberImpl";
+        String expectedOut = base + "/addNumbers2";
+        assertTrue(output.toString().indexOf(expectedOut) != -1);
+        
+        String expectedIn = base + "/addNumbers2Response";
+        assertTrue(input.toString().indexOf(expectedIn) != -1);
+    }
+
+    @Test
+    public void testAddNumbers3Fault() {
+        ByteArrayOutputStream input = setupInLogging();
+        ByteArrayOutputStream output = setupOutLogging();
+
+        AddNumberImpl port = getPort();
+
+        try {
+            port.addNumbers3(-1, 2);
+        } catch (AddNumbersException_Exception e) {
+            assert true;
+        } catch (Exception e) {
+            e.printStackTrace();
+            assert false;
+        }
+
+        assertTrue(output.toString().indexOf("http://cxf.apache.org/input") != -1);
+        assertTrue(input.toString().indexOf("http://cxf.apache.org/fault3") != -1);
     }
 
     private AddNumberImpl getPort() {

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromjava/server/Server.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromjava/server/Server.java?rev=601261&r1=601260&r2=601261&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromjava/server/Server.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromjava/server/Server.java
Wed Dec  5 01:13:14 2007
@@ -27,7 +27,7 @@
 
     protected void run() {
         Object implementor = new AddNumberImpl();
-        String address = "http://localhost:9092/AddNumberImplPort";
+        String address = "http://localhost:9093/AddNumberImplPort";
         
         EndpointImpl ep = new EndpointImpl(implementor);
 

Modified: incubator/cxf/trunk/systests/src/test/resources/wsdl/add_numbers-fromjava.wsdl
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/resources/wsdl/add_numbers-fromjava.wsdl?rev=601261&r1=601260&r2=601261&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/src/test/resources/wsdl/add_numbers-fromjava.wsdl (original)
+++ incubator/cxf/trunk/systests/src/test/resources/wsdl/add_numbers-fromjava.wsdl Wed Dec
 5 01:13:14 2007
@@ -155,7 +155,7 @@
     </wsdl:binding>
     <wsdl:service name="AddNumberImplService">
 	<wsdl:port name="AddNumberImplPort" binding="tns:AddNumberImplServiceSoapBinding">
-	    <soap:address location="http://localhost:9092/AddNumberImplPort"/>
+	    <soap:address location="http://localhost:9093/AddNumberImplPort"/>
 	</wsdl:port>
     </wsdl:service>
 </wsdl:definitions>



Mime
View raw message