You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by ff...@apache.org on 2009/03/21 03:59:24 UTC

svn commit: r756865 - in /servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src: main/java/org/apache/servicemix/cxfbc/ test/java/org/apache/servicemix/cxfbc/ws/rm/

Author: ffang
Date: Sat Mar 21 02:59:23 2009
New Revision: 756865

URL: http://svn.apache.org/viewvc?rev=756865&view=rev
Log:
[SMXCOMP-476]A CXF-BC provider used with WS-RM sends the CreateSequence request without SOAP envelope

Added:
    servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/ws/rm/CxfBcRMProviderTest.java   (with props)
Modified:
    servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcProvider.java
    servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcProviderMessageObserver.java

Modified: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcProvider.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcProvider.java?rev=756865&r1=756864&r2=756865&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcProvider.java (original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcProvider.java Sat Mar 21 02:59:23 2009
@@ -56,6 +56,7 @@
 
 import org.apache.cxf.binding.soap.SoapMessage;
 import org.apache.cxf.binding.soap.SoapVersion;
+import org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor;
 import org.apache.cxf.binding.soap.interceptor.SoapActionOutInterceptor;
 import org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor;
 import org.apache.cxf.binding.soap.interceptor.SoapPreProtocolOutInterceptor;
@@ -71,6 +72,7 @@
 import org.apache.cxf.interceptor.AttachmentOutInterceptor;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.interceptor.StaxInInterceptor;
 import org.apache.cxf.interceptor.StaxOutInterceptor;
 
 import org.apache.cxf.message.Exchange;
@@ -561,6 +563,10 @@
                 CxfBcProviderMessageObserver obs = new CxfBcProviderMessageObserver(
                         this);
                 conduit.setMessageObserver(obs);
+
+                checkWSRMInterceptors();
+                          
+
                 super.validate();
             }
         } catch (DeploymentException e) {
@@ -570,6 +576,20 @@
         }
     }
 
+    private void checkWSRMInterceptors() {
+        //to handle WS-RM requests and responses
+        for (Interceptor interceptor : getBus().getOutInterceptors()) {
+            if (interceptor.getClass().getName().equals("org.apache.cxf.ws.rm.RMOutInterceptor")) {
+                ep.getOutInterceptors().add(new SoapOutInterceptor(getBus()));
+                ep.getOutInterceptors().add(new StaxOutInterceptor());
+                ep.getInInterceptors().add(new StaxInInterceptor());
+                ep.getInInterceptors().add(new ReadHeadersInterceptor(getBus()));
+                break;
+            }
+        }
+
+    }
+
     @Override
     public void start() throws Exception {
         applyFeatures();

Modified: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcProviderMessageObserver.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcProviderMessageObserver.java?rev=756865&r1=756864&r2=756865&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcProviderMessageObserver.java (original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcProviderMessageObserver.java Sat Mar 21 02:59:23 2009
@@ -81,6 +81,14 @@
     public void onMessage(Message message) {
         try {
             MessageExchange messageExchange = message.getExchange().get(MessageExchange.class);
+            if (messageExchange == null) {
+                // probably, that's a WS-RM Response; use the messageObserver defined in exchange
+                MessageObserver messageObserver = message.getExchange().get(MessageObserver.class);
+                if (messageObserver != null) {
+                    messageObserver.onMessage(message);
+                }
+                return;
+            }
             if (messageExchange.getStatus() != ExchangeStatus.ACTIVE) {
                 return;
             }

Added: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/ws/rm/CxfBcRMProviderTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/ws/rm/CxfBcRMProviderTest.java?rev=756865&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/ws/rm/CxfBcRMProviderTest.java (added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/ws/rm/CxfBcRMProviderTest.java Sat Mar 21 02:59:23 2009
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.cxfbc.ws.rm;
+
+import java.net.URI;
+import java.util.logging.Logger;
+
+import javax.jbi.messaging.InOut;
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.calculator.CalculatorImpl;
+import org.apache.cxf.calculator.CalculatorPortType;
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.interceptor.LoggingInInterceptor;
+import org.apache.cxf.interceptor.LoggingOutInterceptor;
+import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
+import org.apache.cxf.service.model.ServiceInfo;
+import org.apache.servicemix.client.DefaultServiceMixClient;
+import org.apache.servicemix.cxfbc.CxfBcComponent;
+import org.apache.servicemix.cxfbc.CxfBcEndpointType;
+import org.apache.servicemix.cxfbc.CxfBcProvider;
+import org.apache.servicemix.jbi.container.JBIContainer;
+import org.apache.servicemix.jbi.jaxp.SourceTransformer;
+import org.apache.servicemix.jbi.jaxp.StringSource;
+
+import org.springframework.core.io.ClassPathResource;
+
+
+public class CxfBcRMProviderTest extends TestCase {
+
+    private static final Logger LOG = LogUtils.getL7dLogger(org.apache.servicemix.cxfbc.CxfBcProviderTest.class);
+    
+    private DefaultServiceMixClient client;
+    private InOut io;
+    private JaxWsServerFactoryBean factory;
+    private Server server;
+    private Endpoint endpoint;
+    private ServiceInfo service;
+    
+    private JBIContainer jbi;
+
+    protected void setUp() throws Exception {
+    }
+
+    protected void tearDown() throws Exception {
+    }
+
+        
+    private void localTestProvider(boolean withRM) throws Exception {
+        LOG.info("test provider withRM=" + withRM);
+           
+        
+        //start external service
+        if (withRM) {
+            SpringBusFactory bf = new SpringBusFactory();
+            Bus serverBus = bf.createBus("org/apache/servicemix/cxfbc/ws/rm/rminterceptors.xml");
+            BusFactory.setDefaultBus(serverBus);
+        }
+        factory = new JaxWsServerFactoryBean();
+        factory.setServiceClass(CalculatorPortType.class);
+        factory.setServiceBean(new CalculatorImpl());
+        String address = "http://localhost:9001/providertest";
+        factory.setAddress(address);
+        factory.setBindingId("http://schemas.xmlsoap.org/wsdl/soap12/");
+        server = factory.create();
+        endpoint = server.getEndpoint();
+        endpoint.getInInterceptors().add(new LoggingInInterceptor());
+        endpoint.getOutInterceptors().add(new LoggingOutInterceptor());
+        service = endpoint.getEndpointInfo().getService();
+        assertNotNull(service);
+
+        jbi = new JBIContainer();
+        jbi.setEmbedded(true);
+        jbi.init();
+        jbi.start();
+
+        CxfBcComponent comp = new CxfBcComponent();
+        CxfBcProvider ep = new CxfBcProvider();
+        if (withRM) {
+            ep.setBusCfg("org/apache/servicemix/cxfbc/ws/rm/rminterceptors.xml");
+        }
+        ep.setWsdl(new ClassPathResource("/wsdl/calculator.wsdl"));
+        ep.setLocationURI(new URI("http://localhost:9001/providertest"));
+        ep.setEndpoint("CalculatorPort");
+        ep.setService(new QName("http://apache.org/cxf/calculator", "CalculatorService"));
+        ep.setInterfaceName(new QName("http://apache.org/cxf/calculator", "CalculatorPortType"));
+        comp.setEndpoints(new CxfBcEndpointType[] {ep});
+        jbi.activateComponent(comp, "servicemix-cxfbc");
+        client = new DefaultServiceMixClient(jbi);
+        io = client.createInOutExchange();
+        io.setService(new QName("http://apache.org/cxf/calculator", "CalculatorService"));
+        io.setInterfaceName(new QName("http://apache.org/cxf/calculator", "CalculatorPortType"));
+        io.setOperation(new QName("http://apache.org/cxf/calculator", "add"));
+        //send message
+        io.getInMessage().setContent(new StringSource(
+                "<message xmlns='http://java.sun.com/xml/ns/jbi/wsdl-11-wrapper'>"
+              + "<part>"
+              + "<add xmlns='http://apache.org/cxf/calculator/types'><arg0>10</arg0>"
+              + "<arg1>5</arg1></add>"
+              + "</part>"
+              + "</message>"));
+        client.sendSync(io);
+        client.done(io);
+        assertTrue(new SourceTransformer().contentToString(
+                io.getOutMessage()).indexOf("<return>15</return>") >= 0);
+
+        // Shutdown CXF Service/Endpoint so that next test doesn't fail.
+        factory.getBus().shutdown(true);
+        // Shutdown jbi
+        jbi.shutDown();
+    }    
+
+    public void testProvider() throws Exception {
+        localTestProvider(true);
+    }
+
+}

Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/ws/rm/CxfBcRMProviderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/ws/rm/CxfBcRMProviderTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date