cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject svn commit: r1165627 - in /cxf/branches/2.4.x-fixes: ./ rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/interceptor/ rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws...
Date Tue, 06 Sep 2011 12:08:19 GMT
Author: ay
Date: Tue Sep  6 12:08:18 2011
New Revision: 1165627

URL: http://svn.apache.org/viewvc?rev=1165627&view=rev
Log:
Merged revisions 1165593 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1165593 | ay | 2011-09-06 12:22:08 +0200 (Tue, 06 Sep 2011) | 1 line
  
  [CXF-3783] Provide an option for the dispatch client to automatically set the correct SOAPAction
based on the message payload
........

Added:
    cxf/branches/2.4.x-fixes/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/interceptor/SoapPreProtocolOutInterceptorTest.java
      - copied unchanged from r1165593, cxf/trunk/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/interceptor/SoapPreProtocolOutInterceptorTest.java
    cxf/branches/2.4.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/sayHi2.xml
      - copied unchanged from r1165593, cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/sayHi2.xml
Modified:
    cxf/branches/2.4.x-fixes/   (props changed)
    cxf/branches/2.4.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapPreProtocolOutInterceptor.java
    cxf/branches/2.4.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java
    cxf/branches/2.4.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/dispatch/DispatchTest.java
    cxf/branches/2.4.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java
    cxf/branches/2.4.x-fixes/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/MAPAggregatorTest.java

Propchange: cxf/branches/2.4.x-fixes/
------------------------------------------------------------------------------
    svn:mergeinfo = /cxf/trunk:1165593

Propchange: cxf/branches/2.4.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.4.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapPreProtocolOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapPreProtocolOutInterceptor.java?rev=1165627&r1=1165626&r2=1165627&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapPreProtocolOutInterceptor.java
(original)
+++ cxf/branches/2.4.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapPreProtocolOutInterceptor.java
Tue Sep  6 12:08:18 2011
@@ -140,6 +140,11 @@ public class SoapPreProtocolOutIntercept
             if (boi == null) {
                 action = "\"\"";
             } else {
+                BindingOperationInfo dboi = 
+                    (BindingOperationInfo)boi.getProperty("dispatchToOperation");
+                if (null != dboi) {
+                    boi = dboi;
+                }
                 SoapOperationInfo soi = (SoapOperationInfo) boi.getExtensor(SoapOperationInfo.class);
                 action = soi == null ? "\"\"" : soi.getAction() == null ? "\"\"" : soi.getAction();
             }

Modified: cxf/branches/2.4.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java?rev=1165627&r1=1165626&r2=1165627&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java
(original)
+++ cxf/branches/2.4.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java
Tue Sep  6 12:08:18 2011
@@ -304,7 +304,8 @@ public class DispatchImpl<T> implements 
                 getRequestContext().put("unwrap.jaxb.element", unwrapProperty);
             }
             QName opName = (QName)getRequestContext().get(MessageContext.WSDL_OPERATION);
-                       
+            boolean findDispatchOp = Boolean.TRUE.equals(getRequestContext().get("find.dispatch.operation"));
+            
             if (opName == null) {
                 opName = isOneWay ? INVOKE_ONEWAY_QNAME : INVOKE_QNAME;
             } else {
@@ -315,28 +316,31 @@ public class DispatchImpl<T> implements 
                 }
             }
             
-            //CXF-2836 : find the operation for the dispatched object 
-            boolean wsaEnabled = false;
-            // the feature list to be searched is the endpoint and the bus's lists
-            List<AbstractFeature> endpointFeatures 
-                = ((JaxWsClientEndpointImpl)client.getEndpoint()).getFeatures();
-            List<AbstractFeature> allFeatures;
-            if (client.getBus().getFeatures() != null) {
-                allFeatures = new ArrayList<AbstractFeature>(endpointFeatures.size()

-                    + client.getBus().getFeatures().size());
-                allFeatures.addAll(endpointFeatures);
-                allFeatures.addAll(client.getBus().getFeatures());
-            } else {
-                allFeatures = endpointFeatures;
-            }
-            for (AbstractFeature feature : allFeatures) {
-                if (feature instanceof WSAddressingFeature) {
-                    wsaEnabled = true; 
+            //CXF-2836 : find the operation for the dispatched object
+            // if findDispatchOp is already true, skip the addressing feature lookup.
+            // if the addressing feature is enabled, set findDispatchOp to true
+            if (!findDispatchOp) {
+                // the feature list to be searched is the endpoint and the bus's lists
+                List<AbstractFeature> endpointFeatures 
+                    = ((JaxWsClientEndpointImpl)client.getEndpoint()).getFeatures();
+                List<AbstractFeature> allFeatures;
+                if (client.getBus().getFeatures() != null) {
+                    allFeatures = new ArrayList<AbstractFeature>(endpointFeatures.size()

+                        + client.getBus().getFeatures().size());
+                    allFeatures.addAll(endpointFeatures);
+                    allFeatures.addAll(client.getBus().getFeatures());
+                } else {
+                    allFeatures = endpointFeatures;
+                }
+                for (AbstractFeature feature : allFeatures) {
+                    if (feature instanceof WSAddressingFeature) {
+                        findDispatchOp = true; 
+                    }
                 }
             }
             Map<String, QName> payloadOPMap = 
                 createPayloadEleOpNameMap(client.getEndpoint().getBinding().getBindingInfo());
-            if (wsaEnabled && !payloadOPMap.isEmpty()) {
+            if (findDispatchOp && !payloadOPMap.isEmpty()) {
                 String payloadElementName = null;              
                 if (obj instanceof javax.xml.transform.Source) {
                     try {
@@ -360,10 +364,15 @@ public class DispatchImpl<T> implements 
 
                 if (payloadElementName != null) {
                     QName dispatchedOpName = payloadOPMap.get(payloadElementName);
-                    BindingOperationInfo bop = client.getEndpoint().getBinding().getBindingInfo()
-                        .getOperation(opName);
-                    if (bop != null) {
-                        bop.setProperty("dispatchToOperation", dispatchedOpName);
+                    if (null != dispatchedOpName) {
+                        BindingOperationInfo bop = client.getEndpoint().getBinding().getBindingInfo()
+                          .getOperation(opName);
+                        BindingOperationInfo dbop = client.getEndpoint().getBinding().getBindingInfo()
+                          .getOperation(dispatchedOpName);
+                        if (bop != null) {
+                            // set the actual binding operation object to this dispatch operation
+                            bop.setProperty("dispatchToOperation", dbop);
+                        }
                     }
                 }
             } 

Modified: cxf/branches/2.4.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/dispatch/DispatchTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/dispatch/DispatchTest.java?rev=1165627&r1=1165626&r2=1165627&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/dispatch/DispatchTest.java
(original)
+++ cxf/branches/2.4.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/dispatch/DispatchTest.java
Tue Sep  6 12:08:18 2011
@@ -34,8 +34,11 @@ import javax.xml.ws.soap.SOAPFaultExcept
 import org.w3c.dom.Document;
 
 import org.apache.cxf.Bus;
+import org.apache.cxf.binding.soap.SoapMessage;
+import org.apache.cxf.binding.soap.interceptor.AbstractSoapInterceptor;
 import org.apache.cxf.bus.spring.SpringBusFactory;
 import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.interceptor.Interceptor;
 import org.apache.cxf.interceptor.LoggingInInterceptor;
 import org.apache.cxf.jaxws.AbstractJaxWsTest;
@@ -43,6 +46,8 @@ import org.apache.cxf.jaxws.DispatchImpl
 import org.apache.cxf.jaxws.MessageReplayObserver;
 import org.apache.cxf.jaxws.ServiceImpl;
 import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.service.model.BindingOperationInfo;
 import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.transport.Destination;
 import org.apache.hello_world_soap_http.SOAPService;
@@ -98,7 +103,7 @@ public class DispatchTest extends Abstra
 
         d.setMessageObserver(new MessageReplayObserver("/org/apache/cxf/jaxws/sayHiResponse.xml"));
 
-        Document doc = DOMUtils.readXml(getResourceAsStream("/org/apache/cxf/jaxws/sayHi.xml"));
+        Document doc = DOMUtils.readXml(getResourceAsStream("/org/apache/cxf/jaxws/sayHi2.xml"));
         DOMSource source = new DOMSource(doc);
         Source res = disp.invoke(source);
         assertNotNull(res);
@@ -163,5 +168,46 @@ public class DispatchTest extends Abstra
         }
         assertTrue("The LoggingInInterceptor is not configured to dispatch client", exists);
     }
+
+    @Test
+    public void testFindOperationWithSource() throws Exception {
+        ServiceImpl service = 
+            new ServiceImpl(getBus(), getClass().getResource("/wsdl/hello_world.wsdl"), serviceName,
null);
+
+        Dispatch<Source> disp = service.createDispatch(portName, Source.class, Service.Mode.MESSAGE);
+        disp.getRequestContext().put(Dispatch.ENDPOINT_ADDRESS_PROPERTY, address);
+        disp.getRequestContext().put("find.dispatch.operation", Boolean.TRUE);
+        
+        d.setMessageObserver(new MessageReplayObserver("/org/apache/cxf/jaxws/sayHiResponse.xml"));
+
+        BindingOperationVerifier bov = new BindingOperationVerifier();
+        ((DispatchImpl)disp).getClient().getOutInterceptors().add(bov);
+
+        Document doc = DOMUtils.readXml(getResourceAsStream("/org/apache/cxf/jaxws/sayHi2.xml"));
+        DOMSource source = new DOMSource(doc);
+        Source res = disp.invoke(source);
+        assertNotNull(res);
+
+        BindingOperationInfo boi = bov.getBindingOperationInfo();
+        assertNotNull(boi);
+        BindingOperationInfo dboi = (BindingOperationInfo)boi.getProperty("dispatchToOperation");
+        assertNotNull(dboi);
+
+        assertEquals(new QName("http://apache.org/hello_world_soap_http", "sayHi"), dboi.getName());
+    }
     
+    private static class BindingOperationVerifier extends AbstractSoapInterceptor {
+        BindingOperationInfo boi;
+        public BindingOperationVerifier() {
+            super(Phase.POST_LOGICAL);
+        }
+        
+        public void handleMessage(SoapMessage message) throws Fault {
+            boi = message.getExchange().getBindingOperationInfo();
+        }
+        
+        public BindingOperationInfo getBindingOperationInfo() {
+            return boi;
+        }
+    }
 }

Modified: cxf/branches/2.4.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java?rev=1165627&r1=1165626&r2=1165627&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java
(original)
+++ cxf/branches/2.4.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java
Tue Sep  6 12:08:18 2011
@@ -778,21 +778,12 @@ public class MAPAggregator extends Abstr
             op = ((UnwrappedOperationInfo)op).getWrappedOperation();
         }
         //CXF-2836:To correct the wsa:action header value for dispatch client
-        if (bop.getProperty("dispatchToOperation") != null) {
+        BindingOperationInfo dbop = (BindingOperationInfo)bop.getProperty("dispatchToOperation");
+        if (null != dbop) {
             //modifies the bop and bp to the value of dispatch client really invokes, 
             //This helps corrct the wsa:action header value
-            QName opName = (QName)bop.getProperty("dispatchToOperation");
-            OperationInfo dispatchOP = bop.getBinding().getService().getInterface().getOperation(opName);
-            BindingOperationInfo dispachBop = null;
-            for (BindingOperationInfo binfo : bop.getBinding().getOperations()) {
-                if (binfo.getOperationInfo().getName().toString().equals(opName.toString()))
{
-                    dispachBop = binfo;
-                }
-            }
-            if (dispachBop != null && dispatchOP != null) {
-                bop = dispachBop;
-                op = dispatchOP;
-            }
+            bop = dbop;
+            op = dbop.getOperationInfo();
         }
         
         String actionUri = null;

Modified: cxf/branches/2.4.x-fixes/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/MAPAggregatorTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/MAPAggregatorTest.java?rev=1165627&r1=1165626&r2=1165627&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/MAPAggregatorTest.java
(original)
+++ cxf/branches/2.4.x-fixes/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/MAPAggregatorTest.java
Tue Sep  6 12:08:18 2011
@@ -439,7 +439,31 @@ public class MAPAggregatorTest extends A
         assertSame(replyTo, props.getReplyTo());
     }
 
-    
+    @Test
+    public void testGetActionUriForNormalOp() throws Exception {
+        Message message = setUpMessage(true, true, false, true, true);
+        String action = aggregator.getActionUri(message, false);
+        control.verify();
+        assertEquals("http://foo/bar/SEI/opRequest", action);
+    }
+    
+    @Test
+    public void testGetActionUriForDispatchOp() throws Exception {
+        Message message = setUpMessage(true, true, false, true, true);
+        BindingOperationInfo dbop = setUpBindingOperationInfo("http://foo/bar/d",
+                                                              "opDRequest",
+                                                              "opDResponse",
+                                                              "opDFault", 
+                                                              DSEI.class.getMethod("op",
new Class[0]));
+
+        BindingOperationInfo bop = message.getExchange().get(BindingOperationInfo.class);
+        bop.setProperty("dispatchToOperation", dbop);
+
+        String action = aggregator.getActionUri(message, false);
+        control.verify();
+        assertEquals("http://foo/bar/d/DSEI/opDRequest", action);
+    }
+
     private Message setUpMessage(boolean requestor, 
                                  boolean outbound,
                                  boolean oneway) 
@@ -583,17 +607,17 @@ public class MAPAggregatorTest extends A
         List<ExtensibilityElement> endpointExts =
             new ArrayList<ExtensibilityElement>();
         endpointInfo.getExtensors(EasyMock.eq(ExtensibilityElement.class));
-        EasyMock.expectLastCall().andReturn(endpointExts);
+        EasyMock.expectLastCall().andReturn(endpointExts).anyTimes();
         BindingInfo bindingInfo = control.createMock(BindingInfo.class);
         endpointInfo.getBinding();
         EasyMock.expectLastCall().andReturn(bindingInfo).anyTimes();
         bindingInfo.getExtensors(EasyMock.eq(ExtensibilityElement.class));
-        EasyMock.expectLastCall().andReturn(Collections.EMPTY_LIST);
+        EasyMock.expectLastCall().andReturn(Collections.EMPTY_LIST).anyTimes();
         ServiceInfo serviceInfo = control.createMock(ServiceInfo.class);
         endpointInfo.getService();
-        EasyMock.expectLastCall().andReturn(serviceInfo).times(2);
+        EasyMock.expectLastCall().andReturn(serviceInfo).anyTimes();
         serviceInfo.getExtensors(EasyMock.eq(ExtensibilityElement.class));
-        EasyMock.expectLastCall().andReturn(Collections.EMPTY_LIST);
+        EasyMock.expectLastCall().andReturn(Collections.EMPTY_LIST).anyTimes();
         ExtensibilityElement ext = 
             control.createMock(ExtensibilityElement.class);
         if (usingAddressing) {
@@ -601,7 +625,7 @@ public class MAPAggregatorTest extends A
                 ? Names.WSAW_USING_ADDRESSING_QNAME 
                 : new QName(SOAP_NAMESPACE, "encodingStyle");
             ext.getElementType();
-            EasyMock.expectLastCall().andReturn(elementType);
+            EasyMock.expectLastCall().andReturn(elementType).anyTimes();
             endpointExts.add(ext);
         }
     }
@@ -786,19 +810,10 @@ public class MAPAggregatorTest extends A
     
     private void setUpMethod(Message message, Exchange exchange, Method method) {
         setUpMessageExchange(message, exchange);
-        ServiceInfo si = new ServiceInfo();
-        InterfaceInfo iinf = new InterfaceInfo(si, new QName("http://foo/bar", "SEI"));
-        OperationInfo opInfo = iinf.addOperation(new QName("http://foo/bar", method.getName()));
-        opInfo.setProperty(Method.class.getName(), method);
-        opInfo.setInput("opRequest",
-                        opInfo.createMessage(new QName("http://foo/bar", "opRequest"), Type.INPUT));
-        opInfo.setOutput("opResponse",
-                         opInfo.createMessage(new QName("http://foo/bar", "opResponse"),
Type.INPUT));
-        FaultInfo finfo = opInfo.addFault(new QName("http://foo/bar", "opFault"),
-                new QName("http://foo/bar", "opFault"));
-        finfo.addMessagePart("fault");
-        
-        BindingOperationInfo bindingOpInfo = new TestBindingOperationInfo(opInfo);
+        BindingOperationInfo bindingOpInfo = setUpBindingOperationInfo("http://foo/bar",
+                                                                       "opRequest",
+                                                                       "opResponse",
+                                                                       "opFault", method);
         setUpExchangeGet(exchange, BindingOperationInfo.class, bindingOpInfo);
         // Usual fun with EasyMock not always working as expected
         //BindingOperationInfo bindingOpInfo =
@@ -810,6 +825,25 @@ public class MAPAggregatorTest extends A
         //EasyMock.expectLastCall().andReturn(method);
     }
     
+    private BindingOperationInfo setUpBindingOperationInfo(String nsuri, 
+                                                           String opreq,
+                                                           String opresp,
+                                                           String opfault, Method method)
{
+        ServiceInfo si = new ServiceInfo();
+        InterfaceInfo iinf = new InterfaceInfo(si, 
+                                               new QName(nsuri, method.getDeclaringClass().getSimpleName()));
+        OperationInfo opInfo = iinf.addOperation(new QName(nsuri, method.getName()));
+        opInfo.setProperty(Method.class.getName(), method);
+        opInfo.setInput(opreq, opInfo.createMessage(new QName(nsuri, opreq), Type.INPUT));
+        opInfo.setOutput(opresp, opInfo.createMessage(new QName(nsuri, opresp), Type.INPUT));
+        FaultInfo finfo = opInfo.addFault(new QName(nsuri, opfault), new QName(nsuri, opfault));
+        finfo.addMessagePart("fault");
+        
+        BindingOperationInfo bindingOpInfo = new TestBindingOperationInfo(opInfo);
+        
+        return bindingOpInfo;
+    }
+    
     private Message getMessage() {
         //return control.createMock(Message.class);
         return new MessageImpl();
@@ -938,6 +972,12 @@ public class MAPAggregatorTest extends A
         @ResponseWrapper(targetNamespace = "http://foo/bar", className = "SEI", localName
= "opResponse")
         String op();
     }
+
+    private interface DSEI {
+        @RequestWrapper(targetNamespace = "http://foo/bar/d", className = "DSEI", localName
= "opDRequest")
+        @ResponseWrapper(targetNamespace = "http://foo/bar/d", className = "DSEI", localName
= "opDResponse")
+        String op();
+    }
     
     private static class TestBindingMessageInfo extends BindingMessageInfo {
     }



Mime
View raw message