servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject svn commit: r732230 - 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/provider/ test/resources/org/apache/servicemix/cxfbc/pro...
Date Wed, 07 Jan 2009 05:50:49 GMT
Author: ffang
Date: Tue Jan  6 21:50:49 2009
New Revision: 732230

URL: http://svn.apache.org/viewvc?rev=732230&view=rev
Log:
[SM-1758]cxf provider should be able to extract operationName based on payload and wsdl if
using doc/literal style in case that no operationName bound to the MessageExchange

Added:
    servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/provider/xbean_provider_with_jbi_wrapper.xml
  (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/test/java/org/apache/servicemix/cxfbc/provider/CxfBCSEProviderSystemTest.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=732230&r1=732229&r2=732230&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
Tue Jan  6 21:50:49 2009
@@ -16,6 +16,7 @@
  */
 package org.apache.servicemix.cxfbc;
 
+import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.net.URI;
@@ -34,13 +35,16 @@
 import javax.wsdl.factory.WSDLFactory;
 import javax.wsdl.xml.WSDLReader;
 import javax.xml.namespace.QName;
+import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.transform.Source;
+import javax.xml.transform.TransformerException;
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamSource;
 
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
+import org.xml.sax.SAXException;
 
 import com.ibm.wsdl.Constants;
 
@@ -50,9 +54,13 @@
 import org.apache.cxf.binding.jbi.JBIConstants;
 import org.apache.cxf.binding.jbi.JBIFault;
 
+import org.apache.cxf.binding.soap.SoapMessage;
+import org.apache.cxf.binding.soap.SoapVersion;
 import org.apache.cxf.binding.soap.interceptor.SoapActionOutInterceptor;
 import org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor;
 import org.apache.cxf.binding.soap.interceptor.SoapPreProtocolOutInterceptor;
+import org.apache.cxf.binding.soap.model.SoapBindingInfo;
+import org.apache.cxf.binding.soap.model.SoapBodyInfo;
 import org.apache.cxf.bus.spring.SpringBusFactory;
 import org.apache.cxf.catalog.OASISCatalogManager;
 import org.apache.cxf.endpoint.Client;
@@ -72,6 +80,7 @@
 import org.apache.cxf.phase.PhaseInterceptorChain;
 import org.apache.cxf.phase.PhaseManager;
 import org.apache.cxf.service.Service;
+import org.apache.cxf.service.model.BindingMessageInfo;
 import org.apache.cxf.service.model.BindingOperationInfo;
 import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.service.model.OperationInfo;
@@ -91,6 +100,7 @@
 import org.apache.servicemix.cxfbc.interceptors.JbiOutInterceptor;
 import org.apache.servicemix.cxfbc.interceptors.JbiOutWsdl1Interceptor;
 import org.apache.servicemix.cxfbc.interceptors.MtomCheckInterceptor;
+import org.apache.servicemix.jbi.jaxp.SourceTransformer;
 import org.apache.servicemix.soap.util.DomUtil;
 import org.springframework.core.io.Resource;
 
@@ -163,31 +173,25 @@
         cxfExchange.setConduit(conduit);
         cxfExchange.setSynchronous(isSynchronous());
         cxfExchange.put(MessageExchange.class, exchange);
-
         message.setExchange(cxfExchange);
         cxfExchange.setOutMessage(message);
 
         QName opeName = exchange.getOperation();
         BindingOperationInfo boi = null;
+        
         if (opeName == null) {
             // if interface only have one operation, may not specify the opeName
             // in MessageExchange
             if (ei.getBinding().getOperations().size() == 1) {
                 boi = ei.getBinding().getOperations().iterator().next();
             } else {
-                throw new Fault(new Exception(
-                        "Operation not bound on this MessageExchange"));
-
+                boi = findOperation(nm, message, boi, exchange);
+                cxfExchange.put(MessageExchange.class, exchange);
+                
             }
         } else {
             boi = ei.getBinding().getOperation(exchange.getOperation());
         }
-        cxfExchange.setOneWay(boi.getOperationInfo().isOneWay());
-        cxfExchange.put(BindingOperationInfo.class, boi);
-        cxfExchange.put(Endpoint.class, ep);
-        cxfExchange.put(Service.class, cxfService);
-        cxfExchange.put(Bus.class, getBus());
-        PhaseInterceptorChain outChain = createInterceptorChain(message);
         InputStream is = JBIMessageHelper.convertMessageToInputStream(nm
                 .getContent());
 
@@ -195,6 +199,13 @@
         message.setContent(Source.class, source);
 
         message.setContent(InputStream.class, is);
+        cxfExchange.setOneWay(boi.getOperationInfo().isOneWay());
+        cxfExchange.put(BindingOperationInfo.class, boi);
+        cxfExchange.put(Endpoint.class, ep);
+        cxfExchange.put(Service.class, cxfService);
+        cxfExchange.put(Bus.class, getBus());
+        PhaseInterceptorChain outChain = createInterceptorChain(message);
+        
 
         conduit.prepare(message);
         OutputStream os = message.getContent(OutputStream.class);
@@ -224,6 +235,56 @@
 
     }
 
+    private BindingOperationInfo findOperation(NormalizedMessage nm, 
+                                               Message message, 
+                                               BindingOperationInfo boi, 
+                                               MessageExchange exchange) 
+        throws TransformerException, ParserConfigurationException, IOException, SAXException
{
+        //try to figure out the operationName based on the incoming message
+        //payload and wsdl if use doc/literal/wrapped
+        Element element = new SourceTransformer().toDOMElement(nm.getContent());
+        
+        if (!useJBIWrapper) {
+            SoapVersion soapVersion = ((SoapMessage)message).getVersion();              
 
+            if (element != null) {                                                      
+                Element bodyElement = (Element) element.getElementsByTagNameNS(
+                        element.getNamespaceURI(),
+                        soapVersion.getBody().getLocalPart()).item(0);
+                if (bodyElement != null) {
+                    element = (Element) bodyElement.getFirstChild();                    
      
+                } 
+            }
+        } else {
+            element = DomUtil.getFirstChildElement(DomUtil.getFirstChildElement(element));
+        }
+        
+        QName opeName = new QName(element.getNamespaceURI(), element.getLocalName());
+        SoapBindingInfo binding = (SoapBindingInfo) ei.getBinding();
+        for (BindingOperationInfo op : binding.getOperations()) {
+            String style = binding.getStyle(op.getOperationInfo());
+            if (style == null) {
+                style = binding.getStyle();
+            }
+            if ("document".equals(style)) {
+                BindingMessageInfo msg = op.getInput();
+                if (msg.getExtensor(SoapBodyInfo.class)
+                            .getParts().get(0).getElementQName().equals(opeName)) {
+                    boi = op;
+                    exchange.setOperation(new QName(boi.getName().getNamespaceURI(), opeName.getLocalPart()));
+                    break;
+                }
+            } else {
+                throw new Fault(new Exception(
+                    "Operation must bound on this MessageExchange if use rpc mode"));
+            }
+        }
+        if (boi == null) {
+            throw new Fault(new Exception(
+                "Operation not bound on this MessageExchange"));
+        }
+        return boi;
+    }
+
     private PhaseInterceptorChain createInterceptorChain(Message message) {
         PhaseChainCache outboundChainCache = new PhaseChainCache();
         PhaseManager pm = getBus().getExtension(PhaseManager.class);

Modified: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/provider/CxfBCSEProviderSystemTest.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/provider/CxfBCSEProviderSystemTest.java?rev=732230&r1=732229&r2=732230&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/provider/CxfBCSEProviderSystemTest.java
(original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/provider/CxfBCSEProviderSystemTest.java
Tue Jan  6 21:50:49 2009
@@ -147,7 +147,13 @@
         }
         serversStarted = false;
     }
+    
+    public void testGreetMeProviderWithJBIWrapperWithoutOperationName() throws Exception
{
+        setUpJBI("org/apache/servicemix/cxfbc/provider/xbean_provider_with_jbi_wrapper.xml");
+        greetMeProviderWithoutOperationNameTestBase();
+    }
 
+    
     public void testGreetMeProviderWithOutJBIWrapper() throws Exception {
         setUpJBI("org/apache/servicemix/cxfbc/provider/xbean_provider_without_jbi_wrapper.xml");
         greetMeProviderTestBase(false);
@@ -189,7 +195,6 @@
         io = client.createInOutExchange();
         io.setService(new QName("http://apache.org/hello_world_soap_http_provider", "SOAPService"));
         io.setInterfaceName(new QName("http://apache.org/hello_world_soap_http_provider",
"Greeter"));
-        io.setOperation(new QName("http://apache.org/hello_world_soap_http_provider", "greetMe"));
         //send message to proxy
         io.getInMessage().setContent(new StringSource(
               "<greetMe xmlns='http://apache.org/hello_world_soap_http_provider/types'><requestType>"
@@ -205,6 +210,28 @@
         
     }
     
+    private void greetMeProviderWithoutOperationNameTestBase() throws Exception {
+        client = new DefaultServiceMixClient(jbi);
+        io = client.createInOutExchange();
+        io.setService(new QName("http://apache.org/hello_world_soap_http_provider", "SOAPService"));
+        io.setInterfaceName(new QName("http://apache.org/hello_world_soap_http_provider",
"Greeter"));
+        //send message to proxy
+        io.getInMessage().setContent(new StringSource(
+                "<message xmlns='http://java.sun.com/xml/ns/jbi/wsdl-11-wrapper'>"
+                + "<part> "
+              + "<greetMe xmlns='http://apache.org/hello_world_soap_http_provider/types'><requestType>"
+              + "ffang"
+              + "</requestType></greetMe>"
+              + "</part>"
+              + "</message>"));
+        
+        client.sendSync(io);
+        
+        assertTrue(new SourceTransformer().contentToString(
+                io.getOutMessage()).indexOf("Hello ffang") >= 0);
+    }
+
+    
     private void greetMeProviderJmsTestBase(boolean sync, String name) throws Exception {
 
         client = new DefaultServiceMixClient(jbi);

Added: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/provider/xbean_provider_with_jbi_wrapper.xml
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/provider/xbean_provider_with_jbi_wrapper.xml?rev=732230&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/provider/xbean_provider_with_jbi_wrapper.xml
(added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/provider/xbean_provider_with_jbi_wrapper.xml
Tue Jan  6 21:50:49 2009
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  
+  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.
+  
+-->
+<beans xmlns:sm="http://servicemix.apache.org/config/1.0"
+       xmlns:cxfbc="http://servicemix.apache.org/cxfbc/1.0"
+       xmlns:test="urn:test"
+       xmlns:greeter="http://apache.org/hello_world_soap_http_provider">
+
+       
+  <sm:container id="jbi" embedded="true">
+    
+    <sm:endpoints>      
+      
+            <cxfbc:provider wsdl="./hello_world.wsdl"
+                      locationURI="http://localhost:9000/SoapContext/SoapPort"
+                      endpoint="SoapPort"
+                      service="greeter:SOAPService"
+                      interfaceName="greeter:Greeter"                      
+                      >
+        <cxfbc:inInterceptors>
+          <bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
+        </cxfbc:inInterceptors>
+        <cxfbc:outInterceptors>
+          <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
+        </cxfbc:outInterceptors>
+        <cxfbc:inFaultInterceptors>
+          <bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
+        </cxfbc:inFaultInterceptors>
+        <cxfbc:outFaultInterceptors>
+          <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
+        </cxfbc:outFaultInterceptors>
+      </cxfbc:provider>
+    </sm:endpoints>
+    
+  </sm:container>
+  
+</beans>

Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/provider/xbean_provider_with_jbi_wrapper.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/provider/xbean_provider_with_jbi_wrapper.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/provider/xbean_provider_with_jbi_wrapper.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Mime
View raw message