Author: ningjiang
Date: Fri Apr 1 07:37:55 2011
New Revision: 1087612
URL: http://svn.apache.org/viewvc?rev=1087612&view=rev
Log:
CAMEL-3810 Fixed the issue of camel-cxf soap body and header setting with
PAYLOAD data format
Added:
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/multipart/
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/multipart/CXFMultiPartTest.java
(with props)
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/multipart/MultiPartInvokeImpl.java
(with props)
camel/trunk/components/camel-cxf/src/test/resources/MultiPartTest.wsdl
(with props)
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/multipart/
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/multipart/MultiPartTest.xml
(with props)
Modified:
camel/trunk/components/camel-cxf/pom.xml
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/DefaultCxfBinding.java
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyMessageModeNoSpringTest.java
Modified: camel/trunk/components/camel-cxf/pom.xml
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/pom.xml?rev=1087612&r1=1087611&r2=1087612&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/pom.xml (original)
+++ camel/trunk/components/camel-cxf/pom.xml Fri Apr 1 07:37:55 2011
@@ -240,6 +240,9 @@
<wsdl>${basedir}/src/test/resources/mtom.wsdl</wsdl>
</wsdlOption>
<wsdlOption>
+
<wsdl>${basedir}/src/test/resources/MultiPartTest.wsdl</wsdl>
+ </wsdlOption>
+ <wsdlOption>
<wsdl>${basedir}/src/test/resources/person.wsdl</wsdl>
</wsdlOption>
<wsdlOption>
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=1087612&r1=1087611&r2=1087612&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
Fri Apr 1 07:37:55 2011
@@ -637,7 +637,7 @@ public class CxfEndpoint extends Default
MessageContentsList content = new MessageContentsList();
int i = 0;
- for (MessagePartInfo partInfo :
boi.getOperationInfo().getInput().getMessageParts()) {
+ for (MessagePartInfo partInfo :
boi.getInput().getMessageParts()) {
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/DefaultCxfBinding.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java?rev=1087612&r1=1087611&r2=1087612&view=diff
==============================================================================
---
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java
(original)
+++
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java
Fri Apr 1 07:37:55 2011
@@ -376,7 +376,7 @@ public class DefaultCxfBinding implement
int i = 0;
- for (MessagePartInfo partInfo :
boi.getOperationInfo().getOutput().getMessageParts()) {
+ for (MessagePartInfo partInfo : boi.getOutput().getMessageParts()) {
if (elements.size() > i) {
answer.put(partInfo, elements.get(i++));
Modified:
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyMessageModeNoSpringTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyMessageModeNoSpringTest.java?rev=1087612&r1=1087611&r2=1087612&view=diff
==============================================================================
---
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyMessageModeNoSpringTest.java
(original)
+++
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyMessageModeNoSpringTest.java
Fri Apr 1 07:37:55 2011
@@ -16,7 +16,6 @@
*/
package org.apache.camel.component.cxf;
-import org.apache.camel.Exchange;
public class CXFWsdlOnlyMessageModeNoSpringTest extends
CXFWsdlOnlyPayloadModeNoSpringTest {
Added:
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/multipart/CXFMultiPartTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/multipart/CXFMultiPartTest.java?rev=1087612&view=auto
==============================================================================
---
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/multipart/CXFMultiPartTest.java
(added)
+++
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/multipart/CXFMultiPartTest.java
Fri Apr 1 07:37:55 2011
@@ -0,0 +1,122 @@
+/**
+ * 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.multipart;
+
+import java.io.IOException;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Endpoint;
+import javax.xml.ws.Service;
+
+import junit.framework.TestCase;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.cxf.multipart.MultiPartInvoke;
+import org.apache.camel.cxf.multipart.types.InE;
+import org.apache.camel.cxf.multipart.types.ObjectFactory;
+import org.apache.camel.spring.SpringCamelContext;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.cxf.interceptor.LoggingInInterceptor;
+import org.apache.cxf.interceptor.LoggingOutInterceptor;
+import org.apache.cxf.transport.http.HTTPConduit;
+import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class CXFMultiPartTest extends CamelTestSupport {
+ public static final QName SERVICE_NAME = new
QName("http://camel.apache.org/cxf/multipart",
+
"MultiPartInvokeService");
+
+ public static final QName ROUTE_PORT_NAME = new
QName("http://camel.apache.org/cxf/multipart",
+
"MultiPartInvokePort");
+ protected static Endpoint endpoint;
+ protected AbstractXmlApplicationContext applicationContext;
+
+ @Before
+ public void setUp() throws Exception {
+ applicationContext = createApplicationContext();
+ super.setUp();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+
+ if (applicationContext != null) {
+ applicationContext.destroy();
+ }
+ super.tearDown();
+ }
+
+ @BeforeClass
+ public static void startService() {
+ Object implementor = new MultiPartInvokeImpl();
+ String address = "http://localhost:9000/SoapContext/SoapPort";
+ endpoint = Endpoint.publish(address, implementor);
+
+ }
+
+ @AfterClass
+ public static void stopService() {
+ if (endpoint != null) {
+ endpoint.stop();
+ }
+ }
+
+ @Test
+ public void testInvokingServiceFromCXFClient() throws Exception {
+ String reply =
invokeMultiPartService("http://localhost:9003/CamelContext/RouterPort",
+ "in0", "in1");
+ assertNotNull("No response received from service", reply);
+ assertTrue(reply.equals("in0 in1"));
+
+ assertNotNull("No response received from service", reply);
+ assertTrue(reply.equals("in0 in1"));
+
+ }
+
+ private String invokeMultiPartService(String address, String in0, String
in1) {
+
+ Service service = Service.create(SERVICE_NAME);
+ service.addPort(ROUTE_PORT_NAME, "http://schemas.xmlsoap.org/soap/",
address);
+ MultiPartInvoke multiPartClient = service.getPort(ROUTE_PORT_NAME,
MultiPartInvoke.class);
+
+ InE e0 = new ObjectFactory().createInE();
+ InE e1 = new ObjectFactory().createInE();
+ e0.setV(in0);
+ e1.setV(in1);
+
+ javax.xml.ws.Holder<InE> h = new javax.xml.ws.Holder<InE>();
+ javax.xml.ws.Holder<InE> h1 = new javax.xml.ws.Holder<InE>();
+ multiPartClient.foo(e0, e1, h, h1);
+ return h.value.getV() + " " + h1.value.getV();
+ }
+
+
+ protected CamelContext createCamelContext() throws Exception {
+ return SpringCamelContext.springCamelContext(applicationContext);
+ }
+
+ protected ClassPathXmlApplicationContext createApplicationContext() {
+ return new
ClassPathXmlApplicationContext("org/apache/camel/component/cxf/multipart/MultiPartTest.xml");
+ }
+
+}
Propchange:
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/multipart/CXFMultiPartTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/multipart/CXFMultiPartTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/multipart/MultiPartInvokeImpl.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/multipart/MultiPartInvokeImpl.java?rev=1087612&view=auto
==============================================================================
---
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/multipart/MultiPartInvokeImpl.java
(added)
+++
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/multipart/MultiPartInvokeImpl.java
Fri Apr 1 07:37:55 2011
@@ -0,0 +1,58 @@
+/**
+ * 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.multipart;
+
+import java.util.logging.Logger;
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+import javax.xml.bind.annotation.XmlSeeAlso;
+import javax.xml.ws.Holder;
+
+import org.apache.camel.cxf.multipart.MultiPartInvoke;
+import org.apache.camel.cxf.multipart.types.InE;
+
+
[email protected](
+ serviceName = "MultiPartInvokeService",
+ portName = "MultiPartInvokePort",
+ targetNamespace = "http://adapter.ti.tongtech.com/ws",
+ endpointInterface =
"org.apache.camel.cxf.multipart.MultiPartInvoke")
+
+public class MultiPartInvokeImpl implements MultiPartInvoke {
+
+ private static final Logger LOG =
Logger.getLogger(MultiPartInvokeImpl.class.getName());
+
+ @Override
+ public void foo(InE in, InE in1, Holder<InE> out, Holder<InE> out1) {
+ LOG.info("Executing operation foo");
+ System.out.println(in);
+ System.out.println(in1);
+ try {
+ InE outValue = in;
+ out.value = outValue;
+ InE out1Value = in1;
+ out1.value = out1Value;
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ throw new RuntimeException(ex);
+ }
+ }
+
+}
Propchange:
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/multipart/MultiPartInvokeImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/multipart/MultiPartInvokeImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-cxf/src/test/resources/MultiPartTest.wsdl
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/resources/MultiPartTest.wsdl?rev=1087612&view=auto
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/resources/MultiPartTest.wsdl
(added)
+++ camel/trunk/components/camel-cxf/src/test/resources/MultiPartTest.wsdl Fri
Apr 1 07:37:55 2011
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:tns="http://camel.apache.org/cxf/multipart"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="flow"
+ xmlns:x1="http://camel.apache.org/cxf/multipart/types"
+ targetNamespace="http://camel.apache.org/cxf/multipart">
+ <wsdl:types>
+ <schema targetNamespace="http://camel.apache.org/cxf/multipart/types"
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:x1="http://camel.apache.org/cxf/multipart/types"
+ elementFormDefault="qualified">
+ <element name="inE">
+ <complexType>
+ <sequence>
+ <element name="v" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+ </schema>
+ </wsdl:types>
+ <wsdl:message name="inputRequest">
+ <wsdl:part name="in" element="x1:inE" />
+ <wsdl:part name="in1" element="x1:inE" />
+ </wsdl:message>
+ <wsdl:message name="inputResponse">
+ <wsdl:part name="out" element="x1:inE" />
+ <wsdl:part name="out1" element="x1:inE" />
+ </wsdl:message>
+
+ <wsdl:portType name="MultiPartInvoke">
+ <wsdl:operation name="foo">
+ <wsdl:input message="tns:inputRequest" />
+ <wsdl:output message="tns:inputResponse" />
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="MultiPartInvokeSoapBinding"
type="tns:MultiPartInvoke">
+ <soap:binding style="document"
+ transport="http://schemas.xmlsoap.org/soap/http" />
+ <wsdl:operation name="foo">
+ <soap:operation
soapAction="http://camel.apache.org/cxf/multipart/input" />
+ <wsdl:input>
+ <soap:header use="literal" part="in"
message="tns:inputRequest"/>
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:header use="literal" part="out"
message="tns:inputResponse"/>
+ <soap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="MultiPartInvokeService">
+ <wsdl:port binding="tns:MultiPartInvokeSoapBinding"
name="MultiPartInvokePort">
+ <soap:address
location="http://localhost:9000/SoapContext/SoapPort"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
Propchange:
camel/trunk/components/camel-cxf/src/test/resources/MultiPartTest.wsdl
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
camel/trunk/components/camel-cxf/src/test/resources/MultiPartTest.wsdl
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange:
camel/trunk/components/camel-cxf/src/test/resources/MultiPartTest.wsdl
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added:
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/multipart/MultiPartTest.xml
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/multipart/MultiPartTest.xml?rev=1087612&view=auto
==============================================================================
---
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/multipart/MultiPartTest.xml
(added)
+++
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/multipart/MultiPartTest.xml
Fri Apr 1 07:37:55 2011
@@ -0,0 +1,55 @@
+<?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"
+
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.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="routerEndpoint"
address="http://localhost:9003/CamelContext/RouterPort"
+ wsdlURL="classpath:/MultiPartTest.wsdl"
endpointName="s:MultiPartInvokePort"
+ serviceName="s:MultiPartInvokeService"
+ xmlns:s="http://camel.apache.org/cxf/multipart">
+ <cxf:outInterceptors>
+ <bean
class="org.apache.camel.component.cxf.WriteXmlDeclarationInterceptor"/>
+ </cxf:outInterceptors>
+ </cxf:cxfEndpoint>
+
+ <cxf:cxfEndpoint id="serviceEndpoint"
address="http://localhost:9000/SoapContext/SoapPort"
+ wsdlURL="classpath:MultiPartTest.wsdl"
+ endpointName="s:MultiPartInvokePort"
+ serviceName="s:MultiPartInvokeService"
+ xmlns:s="http://camel.apache.org/cxf/multipart" />
+
+ <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
+ <route errorHandlerRef="noErrorHandler">
+ <from uri="cxf:bean:routerEndpoint?dataFormat=PAYLOAD" />
+ <to uri="cxf:bean:serviceEndpoint?dataFormat=PAYLOAD" />
+ </route>
+ </camelContext>
+
+ <bean id="noErrorHandler"
class="org.apache.camel.builder.NoErrorHandlerBuilder"/>
+
+</beans>
Propchange:
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/multipart/MultiPartTest.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/multipart/MultiPartTest.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange:
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/multipart/MultiPartTest.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml