cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r774446 - in /cxf/trunk: rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ systests/src/test/java/org/apache/cxf/systest/ws/addr_wsdl/
Date Wed, 13 May 2009 17:49:16 GMT
Author: dkulp
Date: Wed May 13 17:49:13 2009
New Revision: 774446

URL: http://svn.apache.org/viewvc?rev=774446&view=rev
Log:
Make sure features are applied for dispatch clients.
Allow specifying operation for displatch clients so policies and actions and stuff on the
operation in the wsdl can be used.
Add test for ws-addressing for dispatch clients

Modified:
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_wsdl/WSAPureWsdlTest.java

Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java?rev=774446&r1=774445&r2=774446&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java (original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java Wed May
13 17:49:13 2009
@@ -38,6 +38,7 @@
 import javax.xml.ws.Response;
 import javax.xml.ws.Service;
 import javax.xml.ws.WebServiceException;
+import javax.xml.ws.handler.MessageContext;
 import javax.xml.ws.handler.MessageContext.Scope;
 import javax.xml.ws.http.HTTPBinding;
 import javax.xml.ws.http.HTTPException;
@@ -248,8 +249,12 @@
                     client.getRequestContext().put(AttachmentOutInterceptor.WRITE_ATTACHMENTS,
Boolean.TRUE);
                 }
             }
-            Object ret[] = client.invokeWrapped(new QName("http://cxf.apache.org/jaxws/dispatch",
-                                                          "Invoke" + (isOneWay ? "OneWay"
: "")),
+            QName opName = (QName)getRequestContext().get(MessageContext.WSDL_OPERATION);
+            if (opName == null) {
+                opName = new QName(DISPATCH_NS,
+                                   isOneWay ? INVOKE_ONEWAY_NAME : INVOKE_NAME);
+            }
+            Object ret[] = client.invokeWrapped(opName,
                                                 obj);
             if (isOneWay) {
                 return null;
@@ -269,10 +274,14 @@
              
         Response<T> ret = new JaxwsResponseCallback<T>(callback);
         try {
+            QName opName = (QName)getRequestContext().get(MessageContext.WSDL_OPERATION);
+            if (opName == null) {
+                opName = new QName(DISPATCH_NS, INVOKE_NAME);
+            }
+
             client.invokeWrapped(callback, 
-                                 new QName("http://cxf.apache.org/jaxws/dispatch",
-                                       "Invoke"),
-                                       obj);
+                                 opName,
+                                 obj);
             
             return ret;
         } catch (Exception ex) {

Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java?rev=774446&r1=774445&r2=774446&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java (original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java Wed May
13 17:49:13 2009
@@ -219,7 +219,7 @@
         portInfos.put(portName, portInfo);
     }
 
-    private Endpoint getJaxwsEndpoint(QName portName, AbstractServiceFactoryBean sf, 
+    private JaxWsClientEndpointImpl getJaxwsEndpoint(QName portName, AbstractServiceFactoryBean
sf, 
                                       WebServiceFeature...features) {
         Service service = sf.getService();
         EndpointInfo ei = null;
@@ -584,11 +584,15 @@
         } catch (ServiceConstructionException e) {
             throw new WebServiceException(e);
         }
-        Endpoint endpoint = getJaxwsEndpoint(portName, sf, features);
+        JaxWsEndpointImpl endpoint = getJaxwsEndpoint(portName, sf, features);
         Client client = new ClientImpl(getBus(), endpoint, clientFac.getConduitSelector());
         for (AbstractFeature af : clientFac.getFeatures()) {
             af.initialize(client, bus);
         }
+        for (AbstractFeature af : endpoint.getFeatures()) {
+            af.initialize(client, bus);
+        }
+        
         if (executor != null) {
             client.getEndpoint().setExecutor(executor);
         }

Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java?rev=774446&r1=774445&r2=774446&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java
(original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java
Wed May 13 17:49:13 2009
@@ -187,7 +187,7 @@
                 || addressingRequired(portExtensors)) {
                 feature.setAddressingRequired(true);
             }
-            addAddressingFeature(new WSAddressingFeature());
+            addAddressingFeature(feature);
         }
     }
     
@@ -280,6 +280,10 @@
             removeAddressingFeature();
         }
     }
+    
+    public List<AbstractFeature> getFeatures() {
+        return features;
+    }
 
     private WSAddressingFeature getWSAddressingFeature() {
         if (features == null) {

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_wsdl/WSAPureWsdlTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_wsdl/WSAPureWsdlTest.java?rev=774446&r1=774445&r2=774446&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_wsdl/WSAPureWsdlTest.java
(original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_wsdl/WSAPureWsdlTest.java
Wed May 13 17:49:13 2009
@@ -20,9 +20,15 @@
 package org.apache.cxf.systest.ws.addr_wsdl;
 
 import java.io.ByteArrayOutputStream;
+import java.io.StringReader;
 import java.net.URL;
 import javax.xml.namespace.QName;
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
 import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Dispatch;
+import javax.xml.ws.Service.Mode;
+import javax.xml.ws.handler.MessageContext;
 
 import org.apache.cxf.systest.ws.AbstractWSATestBase;
 import org.apache.cxf.systest.ws.addr_feature.AddNumbersPortType;
@@ -65,6 +71,59 @@
         assertTrue(output.toString().indexOf(expectedOut) != -1);
         assertTrue(input.toString().indexOf(expectedIn) != -1);
     }
+    @Test
+    public void testBasicDispatchInvocation() throws Exception {
+        String req = "<addNumbers xmlns=\"http://apache.org/cxf/systest/ws/addr_feature/\">"
+            + "<number1>1</number1><number2>2</number2></addNumbers>";
+        String base = "http://apache.org/cxf/systest/ws/addr_feature/AddNumbersPortType/";
+        String expectedOut = base + "addNumbersRequest";
+        String expectedIn = base + "addNumbersResponse</Action>";
+
+        
+        ByteArrayOutputStream input = setupInLogging();
+        ByteArrayOutputStream output = setupOutLogging();
+        
+        URL wsdl = getClass().getResource("/wsdl_systest/add_numbers.wsdl");
+        assertNotNull("WSDL is null", wsdl);
+        AddNumbersService service = new AddNumbersService(wsdl, serviceName);
+
+
+        Dispatch<Source> disp = service.createDispatch(AddNumbersService.AddNumbersPort,
+                                                       Source.class, Mode.PAYLOAD);
+
+        disp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, 
+                                     "http://localhost:9094/jaxws/add");
+
+        //manually set the action
+        disp.getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY,
+                                     expectedOut);
+        disp.invoke(new StreamSource(new StringReader(req)));
+        
+        assertTrue(output.toString().indexOf(expectedOut) != -1);
+        assertTrue(input.toString().indexOf(expectedIn) != -1);
+        
+
+        output.reset();
+        input.reset();
+        
+        disp = service.createDispatch(AddNumbersService.AddNumbersPort,
+                                      Source.class, Mode.PAYLOAD);
+
+        disp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, 
+                                     "http://localhost:9094/jaxws/add");
+        
+        //set the operation name so action can be pulled from the wsdl
+        disp.getRequestContext().put(MessageContext.WSDL_OPERATION, 
+                                     new QName("http://apache.org/cxf/systest/ws/addr_feature/",
+                                               "addNumbers"));
+        
+        disp.invoke(new StreamSource(new StringReader(req)));
+        
+        assertTrue(output.toString().indexOf(expectedOut) != -1);
+        assertTrue(input.toString().indexOf(expectedIn) != -1);
+
+        
+    }
 
     private AddNumbersPortType getPort() {
         URL wsdl = getClass().getResource("/wsdl_systest/add_numbers.wsdl");



Mime
View raw message