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 2008/11/06 11:04:04 UTC

svn commit: r711827 - in /servicemix/components/bindings/servicemix-cxf-bc/trunk/src: main/java/org/apache/servicemix/cxfbc/ main/java/org/apache/servicemix/cxfbc/interceptors/ test/java/org/apache/servicemix/cxfbc/ test/resources/org/apache/servicemix...

Author: ffang
Date: Thu Nov  6 02:03:55 2008
New Revision: 711827

URL: http://svn.apache.org/viewvc?rev=711827&view=rev
Log:
[SM-1573]add useSOAPEnvelope flag support for cxf-bc

Added:
    servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/xbean_without_jbi_wrapper_without_soapenv.xml   (with props)
Modified:
    servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcConsumer.java
    servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcProvider.java
    servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcProviderMessageObserver.java
    servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/interceptors/JbiInWsdl1Interceptor.java
    servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/CxfBCSESystemTest.java

Modified: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcConsumer.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcConsumer.java?rev=711827&r1=711826&r2=711827&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcConsumer.java (original)
+++ servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcConsumer.java Thu Nov  6 02:03:55 2008
@@ -152,6 +152,9 @@
     private long timeout = 0; // default is NO_TIMEOUT
 
     private boolean useJBIWrapper = true;
+    
+    private boolean useSOAPEnvelope = true;
+    
     private EndpointInfo ei;
 
     private boolean started;
@@ -372,7 +375,7 @@
             cxfService.getInInterceptors().add(
                     new JbiOperationInterceptor());
             cxfService.getInInterceptors().add(
-                    new JbiInWsdl1Interceptor(isUseJBIWrapper()));
+                    new JbiInWsdl1Interceptor(isUseJBIWrapper(), isUseSOAPEnvelope()));
             cxfService.getInInterceptors().add(new JbiInInterceptor());
             cxfService.getInInterceptors().add(new JbiJAASInterceptor(
                     AuthenticationService.Proxy.create(
@@ -665,13 +668,14 @@
                     } else {
                         Element details = toElement(exchange.getFault()
                                 .getContent());
-                        
-                        
-                        details = (Element) details.getElementsByTagNameNS(
+                                     
+                        if (isUseSOAPEnvelope()) {
+                        	details = (Element) details.getElementsByTagNameNS(
                                 details.getNamespaceURI(), "Body").item(0);
-                        assert details != null;
-                        details = (Element) details.getElementsByTagNameNS(
+                        	assert details != null;
+                        	details = (Element) details.getElementsByTagNameNS(
                                 details.getNamespaceURI(), "Fault").item(0);
+                        }
                         assert details != null;
                         if (exchange.getProperty("faultstring") != null) {
                             details = (Element) details.getElementsByTagName("faultstring").item(0);
@@ -843,12 +847,13 @@
     }
 
     /**
-          * Specifies if the endpoint expects messages to use the JBI wrapper 
-          * for SOAP messages.
-          *
-          * @param  useJBIWrapper a boolean
-          * @org.apache.xbean.Property description="Specifies if the JBI wrapper is sent in the body of the message. Default is <code>true</code>."
-          **/
+     * Specifies if the endpoint expects messages to use the JBI wrapper 
+     * for SOAP messages.
+     *
+     * @param  useJBIWrapper a boolean
+     * @org.apache.xbean.Property description="Specifies if the JBI wrapper is sent in the body of the message. Default is <code>true</code>.
+     * 	Ignore the value of useSOAPEnvelope if useJBIWrapper is true"
+     **/
     public void setUseJBIWrapper(boolean useJBIWrapper) {
         this.useJBIWrapper = useJBIWrapper;
     }
@@ -858,6 +863,21 @@
     }
    
     /**
+     * Specifies if the endpoint expects soap messages when useJBIWrapper is false, 
+     * if useJBIWrapper is true then ignore useSOAPEnvelope
+     *
+     * @org.apache.xbean.Property description="Specifies if the endpoint expects soap messages when useJBIWrapper is false, 
+     * 				if useJBIWrapper is true then ignore useSOAPEnvelope. The  default is <code>true</code>.
+     * */
+	public void setUseSOAPEnvelope(boolean useSOAPEnvelope) {
+		this.useSOAPEnvelope = useSOAPEnvelope;
+	}
+
+	public boolean isUseSOAPEnvelope() {
+		return useSOAPEnvelope;
+	}
+    
+    /**
      * Specifies if the endpoint expects send messageExchange by sendSync
      * @param  synchronous a boolean
      * @org.apache.xbean.Property description="Specifies if the endpoint expects send messageExchange by sendSync .

Modified: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcProvider.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcProvider.java?rev=711827&r1=711826&r2=711827&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcProvider.java (original)
+++ servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcProvider.java Thu Nov  6 02:03:55 2008
@@ -134,6 +134,8 @@
 
     private boolean useJBIWrapper = true;
     
+    private boolean useSOAPEnvelope = true;
+    
     private boolean synchronous = true;
 
     public void processExchange(MessageExchange exchange) {
@@ -558,7 +560,8 @@
           * for SOAP messages.
           *
           * @param  useJBIWrapper a boolean
-          * @org.apache.xbean.Property description="Specifies if the JBI wrapper is sent in the body of the message. Default is <code>true</code>."
+          * @org.apache.xbean.Property description="Specifies if the JBI wrapper is sent in the body of the message. Default is <code>true</code>.
+          * 	Ignore the value of useSOAPEnvelope if useJBIWrapper is true"
           **/
     public void setUseJBIWrapper(boolean useJBIWrapper) {
         this.useJBIWrapper = useJBIWrapper;
@@ -567,6 +570,21 @@
     public boolean isUseJBIWrapper() {
         return useJBIWrapper;
     }
+    
+    /**
+     * Specifies if the endpoint expects soap messages when useJBIWrapper is false, 
+     * if useJBIWrapper is true then ignore useSOAPEnvelope
+     *
+     * @org.apache.xbean.Property description="Specifies if the endpoint expects soap messages when useJBIWrapper is false, 
+     * 				if useJBIWrapper is true then ignore useSOAPEnvelope. The  default is <code>true</code>.
+     * */
+	public void setUseSOAPEnvelope(boolean useSOAPEnvelope) {
+		this.useSOAPEnvelope = useSOAPEnvelope;
+	}
+
+	public boolean isUseSOAPEnvelope() {
+		return useSOAPEnvelope;
+	}
 
     protected InputStream convertMessageToInputStream(Source src) throws IOException, TransformerException {
         final Transformer transformer = TRANSFORMER_FACTORY.newTransformer();

Modified: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcProviderMessageObserver.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcProviderMessageObserver.java?rev=711827&r1=711826&r2=711827&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcProviderMessageObserver.java (original)
+++ servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcProviderMessageObserver.java Thu Nov  6 02:03:55 2008
@@ -125,7 +125,8 @@
             inList.add(new ReadHeadersInterceptor(this.providerEndpoint.getBus()));
             inList.add(new MustUnderstandInterceptor());
             inList.add(new StaxInInterceptor());
-            inList.add(new JbiInWsdl1Interceptor(this.providerEndpoint.isUseJBIWrapper()));
+            inList.add(new JbiInWsdl1Interceptor(this.providerEndpoint.isUseJBIWrapper(),
+            		this.providerEndpoint.isUseSOAPEnvelope()));
             inList.add(new AttachmentInInterceptor());
             PhaseInterceptorChain inChain = inboundChainCache.get(pm
                     .getInPhases(), inList);

Modified: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/interceptors/JbiInWsdl1Interceptor.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/interceptors/JbiInWsdl1Interceptor.java?rev=711827&r1=711826&r2=711827&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/interceptors/JbiInWsdl1Interceptor.java (original)
+++ servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/interceptors/JbiInWsdl1Interceptor.java Thu Nov  6 02:03:55 2008
@@ -59,11 +59,13 @@
 public class JbiInWsdl1Interceptor extends AbstractSoapInterceptor {
 
     private boolean useJBIWrapper = true;
+    private boolean useSOAPEnvelope = true;
 
-    public JbiInWsdl1Interceptor(boolean useJBIWrapper) {
+    public JbiInWsdl1Interceptor(boolean useJBIWrapper, boolean useSOAPEnvelope) {
         super(Phase.PRE_INVOKE);
         addAfter(JbiOperationInterceptor.class.getName());
         this.useJBIWrapper = useJBIWrapper;
+        this.useSOAPEnvelope = useSOAPEnvelope;
     }
 
     public void handleMessage(SoapMessage message) {
@@ -74,23 +76,28 @@
         Document document = DomUtil.createDocument();
 
         if (!useJBIWrapper) {
-            
-            SoapVersion soapVersion = message.getVersion();
-            Element soapEnv = DomUtil.createElement(document, new QName(
+        	SoapVersion soapVersion = message.getVersion();
+        	if (useSOAPEnvelope) {
+        		Element soapEnv = DomUtil.createElement(document, new QName(
                     soapVersion.getEnvelope().getNamespaceURI(), soapVersion
                             .getEnvelope().getLocalPart(), soapVersion
                             .getPrefix()));
-            Element soapBody = DomUtil.createElement(soapEnv, new QName(
+        		Element soapBody = DomUtil.createElement(soapEnv, new QName(
                     soapVersion.getBody().getNamespaceURI(), soapVersion
                             .getBody().getLocalPart(), soapVersion
                             .getPrefix()));
-            soapEnv.appendChild(soapBody);
-            Element body = getBodyElement(message);
-            
-            if (body != null) {
-                soapBody.appendChild(soapBody.getOwnerDocument().importNode(body,
-                    true));
-            }
+        		soapEnv.appendChild(soapBody);
+        		Element body = getBodyElement(message);
+        		if (body != null) {
+        			soapBody.appendChild(soapBody.getOwnerDocument().importNode(body,
+        					true));
+        		}
+        	} else {
+        		Element body = getBodyElement(message);
+        		if (body != null) {
+                   	document.appendChild(document.importNode(body, true));
+                }
+        	}
         } else {
 
             BindingOperationInfo wsdlOperation = getOperation(message);

Modified: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/CxfBCSESystemTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/CxfBCSESystemTest.java?rev=711827&r1=711826&r2=711827&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/CxfBCSESystemTest.java (original)
+++ servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/CxfBCSESystemTest.java Thu Nov  6 02:03:55 2008
@@ -79,6 +79,11 @@
         calculatorTestBase();
     }
     
+    public void testCalculatrorWithOutJBIWrapperAndSoapEnv() throws Exception {
+        setUpJBI("org/apache/servicemix/cxfbc/xbean_without_jbi_wrapper_without_soapenv.xml");
+        calculatorTestBase();
+    }
+    
     public void testMultipleClientWithJBIWrapper() throws Exception {
         setUpJBI("org/apache/servicemix/cxfbc/xbean.xml");
         multiClientTestBase();

Added: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/xbean_without_jbi_wrapper_without_soapenv.xml
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/xbean_without_jbi_wrapper_without_soapenv.xml?rev=711827&view=auto
==============================================================================
--- servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/xbean_without_jbi_wrapper_without_soapenv.xml (added)
+++ servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/xbean_without_jbi_wrapper_without_soapenv.xml Thu Nov  6 02:03:55 2008
@@ -0,0 +1,71 @@
+<?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:cxfse="http://servicemix.apache.org/cxfse/1.0"
+       xmlns:cxfbc="http://servicemix.apache.org/cxfbc/1.0"
+       xmlns:test="urn:test"
+       xmlns:calculator="http://apache.org/cxf/calculator">
+  
+  <sm:container id="jbi" embedded="true">
+    
+
+    <sm:endpoints>
+      <cxfse:endpoint useJBIWrapper="false" useSOAPEnvelope="false">
+        <cxfse:pojo>
+          <bean class="org.apache.cxf.calculator.CalculatorImpl" />
+        </cxfse:pojo>
+        <cxfse:inInterceptors>
+          <bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
+        </cxfse:inInterceptors>
+        <cxfse:outInterceptors>
+          <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
+        </cxfse:outInterceptors>
+        <cxfse:inFaultInterceptors>
+          <bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
+        </cxfse:inFaultInterceptors>
+        <cxfse:outFaultInterceptors>
+          <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
+        </cxfse:outFaultInterceptors>
+      </cxfse:endpoint>
+      <cxfbc:consumer wsdl="/wsdl/calculator.wsdl"
+                      targetEndpoint="CalculatorPort"
+                      targetService="calculator:CalculatorService"
+                      targetInterface="calculator:CalculatorPortType"
+                      useJBIWrapper="false"
+                      useSOAPEnvelope="false"
+                      >
+        <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:consumer>
+    </sm:endpoints>
+    
+  </sm:container>
+  
+</beans>

Propchange: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/xbean_without_jbi_wrapper_without_soapenv.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/xbean_without_jbi_wrapper_without_soapenv.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/xbean_without_jbi_wrapper_without_soapenv.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml