camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From w...@apache.org
Subject svn commit: r1084433 - in /camel/trunk/components/camel-cxf: ./ src/main/java/org/apache/camel/component/cxf/ src/test/java/org/apache/camel/component/cxf/ src/test/resources/org/apache/camel/component/cxf/
Date Wed, 23 Mar 2011 01:02:40 GMT
Author: wtam
Date: Wed Mar 23 01:02:39 2011
New Revision: 1084433

URL: http://svn.apache.org/viewvc?rev=1084433&view=rev
Log:
[CAMEL-3778] Support CXF Dispatch mode at CXF Endpoint

Added:
    camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultSEI.java
  (with props)
    camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfDispatchMessageTest.java
  (with props)
    camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfDispatchPayloadTest.java
  (with props)
    camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfDispatchTestSupport.java
  (with props)
    camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/CxfDispatchMessageBeans.xml
  (with props)
    camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/CxfDispatchPayloadBeans.xml
  (with props)
Modified:
    camel/trunk/components/camel-cxf/pom.xml
    camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConstants.java
    camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
    camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSpringEndpoint.java

Modified: camel/trunk/components/camel-cxf/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/pom.xml?rev=1084433&r1=1084432&r2=1084433&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/pom.xml (original)
+++ camel/trunk/components/camel-cxf/pom.xml Wed Mar 23 01:02:39 2011
@@ -93,6 +93,12 @@
     <!--  Test Dependencies -->
     <dependency>
       <groupId>org.apache.camel</groupId>
+      <artifactId>camel-core-xml</artifactId>
+      <scope>test</scope>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.apache.camel</groupId>
       <artifactId>camel-test</artifactId>
       <scope>test</scope>
     </dependency>

Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConstants.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConstants.java?rev=1084433&r1=1084432&r2=1084433&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConstants.java
(original)
+++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConstants.java
Wed Mar 23 01:02:39 2011
@@ -42,6 +42,8 @@ public interface CxfConstants {
     String CAMEL_TRANSPORT_PREFIX = "camel:";
     String JAXWS_CONTEXT = "jaxwsContext";
     String CXF_EXCHANGE = "org.apache.cxf.message.exchange";
+    String DISPATCH_NAMESPACE = "http://camel.apache.org/cxf/jaxws/dispatch";
+    String DISPATCH_DEFAULT_OPERATION_NAMESPACE = "Invoke";    
     String CAMEL_EXCHANGE = "org.apache.camel.exchange";
     String CAMEL_CXF_MESSAGE = "CamelCxfMessage";
     String CAMEL_CXF_RS_USING_HTTP_API = "CamelCxfRsUsingHttpAPI";
@@ -53,6 +55,7 @@ public interface CxfConstants {
     String CAMEL_CXF_RS_OPERATION_RESOURCE_INFO_STACK = "CamelCxfRsOperationResourceInfoStack";
     String CAMEL_CXF_ATTACHMENTS = "CamelAttachments";
     String CAMEL_CXF_RS_THROW_EXCEPTION_ON_FAILURE = "CamelCxfRsThrowExceptionOnFailure";
+
 }
 
 

Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java?rev=1084433&r1=1084432&r2=1084433&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
(original)
+++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
Wed Mar 23 01:02:39 2011
@@ -98,6 +98,7 @@ public class CxfEndpoint extends Default
     private boolean loggingFeatureEnabled;
     private String address;
     private boolean mtomEnabled;
+    private boolean skipPayloadMessagePartCheck;
 
     public CxfEndpoint(String remaining, CxfComponent cxfComponent) {
         super(remaining, cxfComponent);
@@ -341,6 +342,16 @@ public class CxfEndpoint extends Default
             ObjectHelper.notEmpty(getServiceClass(), CxfConstants.SERVICE_CLASS);      
         }
         
+        if (getWsdlURL() == null && getServiceClass() == null) {
+            // no WSDL and serviceClass specified, set our default serviceClass
+            setServiceClass(org.apache.camel.component.cxf.DefaultSEI.class.getName());
+            setDefaultOperationNamespace(CxfConstants.DISPATCH_NAMESPACE);
+            setDefaultOperationName(CxfConstants.DISPATCH_DEFAULT_OPERATION_NAMESPACE); 
          
+            if (getDataFormat().equals(DataFormat.PAYLOAD)) { 
+                setSkipPayloadMessagePartCheck(true);
+            }
+        }
+        
         Class<?> cls = null;
         if (getServiceClass() != null) {
             cls = ClassLoaderUtils.loadClass(getServiceClass(), getClass());
@@ -352,6 +363,7 @@ public class CxfEndpoint extends Default
         } else {            
             checkName(portName, "endpoint/port name");
             checkName(serviceName, "service name");
+            
             ClientFactoryBean factoryBean = createClientFactoryBean();
             // setup client factory bean
             setupClientFactoryBean(factoryBean);
@@ -550,6 +562,14 @@ public class CxfEndpoint extends Default
         return loggingFeatureEnabled;
     }
 
+    protected boolean isSkipPayloadMessagePartCheck() {
+        return skipPayloadMessagePartCheck;
+    }
+
+    protected void setSkipPayloadMessagePartCheck(boolean skipPayloadMessagePartCheck) {
+        this.skipPayloadMessagePartCheck = skipPayloadMessagePartCheck;
+    }
+
     @Override
     protected void doStart() throws Exception {
         if (headerFilterStrategy == null) {
@@ -618,8 +638,8 @@ public class CxfEndpoint extends Default
                 int i = 0;
                 
                 for (MessagePartInfo partInfo : boi.getOperationInfo().getInput().getMessageParts())
{
-                    if (elements.size() > i && partInfo.getConcreteName().getLocalPart()
-                        .equals(elements.get(i).getLocalName())) {
+                    if (elements.size() > i && (isSkipPayloadMessagePartCheck()
|| partInfo.getConcreteName().getLocalPart()
+                        .equals(elements.get(i).getLocalName()))) {
                         content.put(partInfo, elements.get(i++));
                     }
                 }

Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSpringEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSpringEndpoint.java?rev=1084433&r1=1084432&r2=1084433&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSpringEndpoint.java
(original)
+++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSpringEndpoint.java
Wed Mar 23 01:02:39 2011
@@ -112,6 +112,17 @@ public class CxfSpringEndpoint extends C
             ObjectHelper.notNull(cls, CxfConstants.SERVICE_CLASS);
         }
 
+        if (getWsdlURL() == null && cls == null) {
+            // no WSDL and serviceClass specified, set our default serviceClass
+            setServiceClass(org.apache.camel.component.cxf.DefaultSEI.class.getName());
+            setDefaultOperationNamespace(CxfConstants.DISPATCH_NAMESPACE);
+            setDefaultOperationName(CxfConstants.DISPATCH_DEFAULT_OPERATION_NAMESPACE); 
             
+            if (getDataFormat().equals(DataFormat.PAYLOAD)) { 
+                setSkipPayloadMessagePartCheck(true);
+            }
+            cls = getSEIClass();
+        }
+        
         if (cls != null) {
             // create client factory bean
             ClientProxyFactoryBean factoryBean = createClientFactoryBean(cls);
@@ -139,6 +150,7 @@ public class CxfSpringEndpoint extends C
 
             return ((ClientProxy)Proxy.getInvocationHandler(factoryBean.create())).getClient();
         } else {
+            
             ClientFactoryBean factoryBean = createClientFactoryBean();
 
             // configure client factory bean by CXF configurer
@@ -269,5 +281,10 @@ public class CxfSpringEndpoint extends C
     public String getEndpointNamespace() {
         return endpointNamespace;
     }
+    
+    @Override
+    public String getWsdlURL() {
+        return bean.getWsdlURL();
+    }
 
 }

Added: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultSEI.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultSEI.java?rev=1084433&view=auto
==============================================================================
--- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultSEI.java
(added)
+++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultSEI.java
Wed Mar 23 01:02:39 2011
@@ -0,0 +1,43 @@
+/**
+ * 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.camel.component.cxf;
+
+import javax.jws.Oneway;
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebService;
+
+import javax.jws.soap.SOAPBinding;
+import javax.jws.soap.SOAPBinding.ParameterStyle;
+
+/**
+ * A Default Service Endpoint Interface (aka serviceClass) to be used if neither explicit

+ * serviceClass and WSDL is specified in a CXF endpoint
+ */
+@SOAPBinding(parameterStyle = ParameterStyle.BARE)
+@WebService(targetNamespace = "http://camel.apache.org/cxf/jaxws/dispatch", name = "DefaultSEI")
+public interface DefaultSEI {
+
+    @Oneway
+    @WebMethod(operationName="InvokeOneWay")
+    void invokeOneWay(@WebParam(partName = "InvokeOneWayRequest",  mode = WebParam.Mode.IN)String
in);
+    
+    @WebMethod(operationName="Invoke")
+    void invoke(@WebParam(partName = "InvokeRequest", mode = WebParam.Mode.IN)String in,
+                   @WebParam(partName = "InvokeResponse",  mode = WebParam.Mode.OUT)String
out);
+}

Propchange: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultSEI.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultSEI.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfDispatchMessageTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfDispatchMessageTest.java?rev=1084433&view=auto
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfDispatchMessageTest.java
(added)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfDispatchMessageTest.java
Wed Mar 23 01:02:39 2011
@@ -0,0 +1,103 @@
+/**
+ * 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.camel.component.cxf;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
+import org.w3c.dom.Document;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.junit.Test;
+import org.springframework.context.support.AbstractApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+
+/**
+ * Unit test for setting arbitrary payload in MESSAGE mode
+ */
+public class CxfDispatchMessageTest extends CxfDispatchTestSupport {
+
+    @Override
+    protected AbstractApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/camel/component/cxf/CxfDispatchMessageBeans.xml");
+    }
+
+    @Test
+    public void testDipatchMessage() throws Exception {
+        final String name = "Tila";
+        Exchange exchange = sendJaxWsDispatchMessage(name, false);
+        assertEquals("The request should be handled sucessfully ", exchange.isFailed(), false);
+        
+        org.apache.camel.Message response = exchange.getOut();
+        assertNotNull("The response message must not be null ", response);
+        
+        String value = decodeResponseFromMessage(response.getBody(InputStream.class), exchange);
+        assertTrue("The response body must match the request ", value.endsWith(name));
+    }
+    
+    @Test
+    public void testDipatchMessageOneway() throws Exception {
+        final String name = "Tila";
+        Exchange exchange = sendJaxWsDispatchMessage(name, true);
+        assertEquals("The request should be handled sucessfully ", exchange.isFailed(), false);
+        
+        org.apache.camel.Message response = exchange.getOut();
+        assertNotNull("The response message must not be null ", response);
+        
+        assertNull("The response body must be null ", response.getBody());
+    }
+
+
+    protected Exchange sendJaxWsDispatchMessage(final String name, final boolean oneway)
{
+        Exchange exchange = template.send("direct:producer", new Processor() {
+            public void process(final Exchange exchange) {
+                InputStream request = encodeRequestInMessage(oneway ? MESSAGE_ONEWAY_TEMPLATE
: MESSAGE_TEMPLATE, name, exchange);
+                exchange.getIn().setBody(request, InputStream.class);
+                // set the operation for oneway; otherwise use the default operation    
           
+                if (oneway) {
+                    exchange.getIn().setHeader(CxfConstants.OPERATION_NAME, INVOKE_ONEWAY_NAME);
+                }
+            }
+        });
+        return exchange;
+    }
+    
+    private static InputStream encodeRequestInMessage(String form, String name, Exchange
exchange) {
+        String payloadstr = String.format(form, name);
+        InputStream message = null;
+        try {
+            message = new ByteArrayInputStream(payloadstr.getBytes("utf-8"));
+        } catch (Exception e) {
+            // ignore and let it fail
+        }
+        return message;
+    }
+
+    private String decodeResponseFromMessage(InputStream message, Exchange exchange) {
+        String value = null;
+        try {
+            Document doc = getDocumentBuilderFactory().newDocumentBuilder().parse(message);
+            value = getResponseType(doc.getDocumentElement());
+        } catch (Exception e) {
+            // ignore and let it fail
+        }
+        return value;
+    }
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfDispatchMessageTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfDispatchMessageTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfDispatchPayloadTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfDispatchPayloadTest.java?rev=1084433&view=auto
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfDispatchPayloadTest.java
(added)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfDispatchPayloadTest.java
Wed Mar 23 01:02:39 2011
@@ -0,0 +1,108 @@
+/**
+ * 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.camel.component.cxf;
+
+import java.io.ByteArrayInputStream;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+import org.junit.Test;
+import org.springframework.context.support.AbstractApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.component.cxf.converter.CxfPayloadConverter;
+import org.apache.cxf.binding.soap.SoapHeader;
+
+
+/**
+ * Unit test for setting arbitrary payload in PAYLOAD mode
+ */
+public class CxfDispatchPayloadTest extends CxfDispatchTestSupport {
+
+    @Override
+    protected AbstractApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/camel/component/cxf/CxfDispatchPayloadBeans.xml");
+    }
+    
+    @Test
+    public void testDispatchPayload() throws Exception {
+        final String name = "Tila";
+        Exchange exchange = sendJaxWsDispatchPayload(name, false);
+        assertEquals("The request should be handled sucessfully ", exchange.isFailed(), false);
+        
+        org.apache.camel.Message response = exchange.getOut();
+        assertNotNull("The response must not be null ", response);
+        
+        String value = decodeResponseFromPayload((CxfPayload<?>)response.getBody(CxfPayload.class),
exchange);
+        assertTrue("The response must match the request ", value.endsWith(name));
+    }
+    
+    @Test
+    public void testDispatchPayloadOneway() throws Exception {
+        final String name = "Tila";
+        Exchange exchange = sendJaxWsDispatchPayload(name, true);
+        assertEquals("The request should be handled sucessfully ", exchange.isFailed(), false);
+        
+        org.apache.camel.Message response = exchange.getOut();
+        assertNotNull("The response must not be null ", response);
+        
+        assertNull("The response must be null ", response.getBody());
+    }
+
+    
+    private Exchange sendJaxWsDispatchPayload(final String name, final boolean oneway) {
+        Exchange exchange = template.send("direct:producer", new Processor() {
+            public void process(final Exchange exchange) {
+                CxfPayload<SoapHeader> request = encodeRequestInPayload(oneway ? PAYLOAD_ONEWAY_TEMPLATE
: PAYLOAD_TEMPLATE, 
+                                                            name, exchange);
+                exchange.getIn().setBody(request, CxfPayload.class);
+                exchange.getIn().setHeader(CxfConstants.OPERATION_NAMESPACE, DISPATCH_NS);
                                   
+                // set the operation for oneway; otherwise use the default operation    
           
+                if (oneway) {
+                    exchange.getIn().setHeader(CxfConstants.OPERATION_NAME, INVOKE_ONEWAY_NAME);
+                }
+            }
+        });
+        return exchange;
+    }
+
+    private static <T> CxfPayload<T> encodeRequestInPayload(String form, String
name, Exchange exchange) {
+        String payloadstr = String.format(form, name);
+        CxfPayload<T> payload = null;
+        try {
+            Document doc = getDocumentBuilderFactory().newDocumentBuilder()
+                                .parse(new ByteArrayInputStream(payloadstr.getBytes("utf-8")));
+            payload = CxfPayloadConverter.documentToCxfPayload(doc, exchange);
+        } catch (Exception e) {
+            // ignore and let it fail
+        }
+        return payload;
+    }
+
+    private <T> String decodeResponseFromPayload(CxfPayload<T> payload, Exchange
exchange) {
+        String value = null;
+        NodeList nodes = CxfPayloadConverter.cxfPayloadToNodeList(payload, exchange);
+        if (nodes != null && nodes.getLength() == 1 && nodes.item(0) instanceof
Element) {
+            value = getResponseType((Element)nodes.item(0));
+        }
+        return value;
+    }
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfDispatchPayloadTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfDispatchPayloadTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfDispatchTestSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfDispatchTestSupport.java?rev=1084433&view=auto
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfDispatchTestSupport.java
(added)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfDispatchTestSupport.java
Wed Mar 23 01:02:39 2011
@@ -0,0 +1,92 @@
+/**
+ * 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.camel.component.cxf;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.ws.Endpoint;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.apache.camel.test.junit4.CamelSpringTestSupport;
+import org.apache.hello_world_soap_http.GreeterImpl;
+
+/**
+ * Base class for testing arbitrary payload
+ */
+public abstract class CxfDispatchTestSupport extends CamelSpringTestSupport {
+    protected static Endpoint endpoint;
+    private static DocumentBuilderFactory documentBuilderFactory;
+    
+    protected static final String DISPATCH_NS = "http://camel.apache.org/cxf/jaxws/dispatch";
+    protected static final String INVOKE_NAME = "Invoke";
+    protected static final String INVOKE_ONEWAY_NAME = "InvokeOneWay";
+
+    protected static final String PAYLOAD_TEMPLATE = "<ns1:greetMe xmlns:ns1=\"http://apache.org/hello_world_soap_http/types\"><ns1:requestType>%s</ns1:requestType></ns1:greetMe>";
+    protected static final String PAYLOAD_ONEWAY_TEMPLATE = "<ns1:greetMeOneWay xmlns:ns1=\"http://apache.org/hello_world_soap_http/types\"><ns1:requestType>%s</ns1:requestType></ns1:greetMeOneWay>";
+    protected static final String MESSAGE_TEMPLATE = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><soap:Body>"

+        + PAYLOAD_TEMPLATE
+        + "</soap:Body></soap:Envelope>";
+    protected static final String MESSAGE_ONEWAY_TEMPLATE = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><soap:Body>"

+        + PAYLOAD_ONEWAY_TEMPLATE
+        + "</soap:Body></soap:Envelope>"; 
+
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
+    @BeforeClass
+    public static void startService() {
+        Object implementor = new GreeterImpl();
+        String address = "http://localhost:9000/SoapContext/GreeterPort";
+        endpoint = Endpoint.publish(address, implementor); 
+    }
+    
+    @AfterClass
+    public static void stopService() {
+        if (endpoint != null) {
+            endpoint.stop();
+        }
+    }
+    
+    protected static String getResponseType(Element node) {
+        NodeList nodes = node.getElementsByTagNameNS("http://apache.org/hello_world_soap_http/types",
"responseType");
+        if (nodes != null && nodes.getLength() == 1) {
+            Node c = nodes.item(0).getFirstChild();
+            if (c != null) {
+                return c.getNodeValue();
+            }
+        }
+        return null;
+    }
+    
+    protected static synchronized DocumentBuilderFactory getDocumentBuilderFactory() {
+        if (documentBuilderFactory == null) {
+            documentBuilderFactory = DocumentBuilderFactory.newInstance();
+            documentBuilderFactory.setNamespaceAware(true);
+            documentBuilderFactory.setIgnoringElementContentWhitespace(true);
+            documentBuilderFactory.setIgnoringComments(true);
+        }
+        return documentBuilderFactory;
+    }
+
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfDispatchTestSupport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfDispatchTestSupport.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/CxfDispatchMessageBeans.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/CxfDispatchMessageBeans.xml?rev=1084433&view=auto
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/CxfDispatchMessageBeans.xml
(added)
+++ camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/CxfDispatchMessageBeans.xml
Wed Mar 23 01:02:39 2011
@@ -0,0 +1,52 @@
+<?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="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:cxf="http://camel.apache.org/schema/cxf"
+       xmlns:camel="http://camel.apache.org/schema/spring"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+       http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd
+       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+    ">
+
+   <import resource="classpath:META-INF/cxf/cxf.xml"/>
+   <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
+   <import resource="classpath:META-INF/cxf/cxf-extension-http-jetty.xml" />
+
+
+   <cxf:cxfEndpoint id="serviceEndpoint" xmlns:s="http://apache.org/hello_world_soap_http"
+		   address="http://localhost:9000/SoapContext/GreeterPort"
+		   endpointName="s:GreeterPort" 
+		   serviceName="s:GreeterService"
+		   bus="#bus">
+
+      <cxf:properties>
+         <entry key="dataFormat" value="MESSAGE"/>
+      </cxf:properties>
+   </cxf:cxfEndpoint>
+      
+
+
+   <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
+      <route>
+         <from uri="direct:producer" />
+         <to uri="cxf:bean:serviceEndpoint?synchronous=true" />
+      </route>
+    </camelContext>
+</beans>
\ No newline at end of file

Propchange: camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/CxfDispatchMessageBeans.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/CxfDispatchMessageBeans.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/CxfDispatchMessageBeans.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/CxfDispatchPayloadBeans.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/CxfDispatchPayloadBeans.xml?rev=1084433&view=auto
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/CxfDispatchPayloadBeans.xml
(added)
+++ camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/CxfDispatchPayloadBeans.xml
Wed Mar 23 01:02:39 2011
@@ -0,0 +1,52 @@
+<?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="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:cxf="http://camel.apache.org/schema/cxf"
+       xmlns:camel="http://camel.apache.org/schema/spring"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+       http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd
+       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+    ">
+
+   <import resource="classpath:META-INF/cxf/cxf.xml"/>
+   <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
+   <import resource="classpath:META-INF/cxf/cxf-extension-http-jetty.xml" />
+
+
+   <cxf:cxfEndpoint id="serviceEndpoint" xmlns:s="http://apache.org/hello_world_soap_http"
+		   address="http://localhost:9000/SoapContext/GreeterPort"
+		   endpointName="s:GreeterPort" 
+		   serviceName="s:GreeterService"
+		   bus="#bus">
+
+      <cxf:properties>
+         <entry key="dataFormat" value="PAYLOAD"/>
+      </cxf:properties>
+   </cxf:cxfEndpoint>
+      
+
+
+   <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
+      <route>
+         <from uri="direct:producer" />
+         <to uri="cxf:bean:serviceEndpoint?synchronous=true" />
+      </route>
+    </camelContext>
+</beans>
\ No newline at end of file

Propchange: camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/CxfDispatchPayloadBeans.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/CxfDispatchPayloadBeans.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/CxfDispatchPayloadBeans.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Mime
View raw message