Author: ningjiang
Date: Mon Aug 18 02:19:42 2008
New Revision: 686705
URL: http://svn.apache.org/viewvc?rev=686705&view=rev
Log:
CAMEL-723 Added some test case to show the difference of the wrapper and
non-wrapper style parameter mapping
Added:
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfNonWrapperTest.java
(with props)
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/non_wrapper/
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/non_wrapper/PersonProcessor.java
(with props)
activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/nonWrapperProcessor.xml
(with props)
activemq/camel/trunk/components/camel-cxf/src/test/resources/person-non-wrapper.wsdl
(with props)
Modified:
activemq/camel/trunk/components/camel-cxf/pom.xml
activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CamelInvoker.java
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/wsdl_first/PersonProcessor.java
Modified: activemq/camel/trunk/components/camel-cxf/pom.xml
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/pom.xml?rev=686705&r1=686704&r2=686705&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/pom.xml (original)
+++ activemq/camel/trunk/components/camel-cxf/pom.xml Mon Aug 18 02:19:42 2008
@@ -302,6 +302,12 @@
<extraarg>-verbose</extraarg>
</extraargs>
</wsdlOption>
+ <wsdlOption>
+
<wsdl>${basedir}/src/test/resources/person-non-wrapper.wsdl</wsdl>
+ <extraargs>
+
<extraarg>-verbose</extraarg>
+ </extraargs>
+ </wsdlOption>
</wsdlOptions>
</configuration>
<goals>
Modified:
activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CamelInvoker.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CamelInvoker.java?rev=686705&r1=686704&r2=686705&view=diff
==============================================================================
---
activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CamelInvoker.java
(original)
+++
activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CamelInvoker.java
Mon Aug 18 02:19:42 2008
@@ -59,6 +59,7 @@
CxfExchange cxfExchange = endpoint.createExchange(inMessage);
BindingOperationInfo bop = exchange.get(BindingOperationInfo.class);
+ cxfExchange.setProperty(BindingOperationInfo.class.toString(), bop);
if (bop != null && bop.getOperationInfo().isOneWay()) {
cxfExchange.setPattern(ExchangePattern.InOnly);
@@ -150,6 +151,7 @@
MethodDispatcher md = (MethodDispatcher)
exchange.get(Service.class).get(MethodDispatcher.class.getName());
Method m = md.getMethod(bop);
+ cxfExchange.setProperty(BindingOperationInfo.class.toString(), bop);
// The SEI could be the provider class which will not have the bop
information.
if (bop != null && bop.getOperationInfo().isOneWay()) {
@@ -163,8 +165,8 @@
} else {
cxfExchange.getIn().setHeader(CxfConstants.OPERATION_NAME,
m.getName());
}
-
-
CxfHeaderHelper.propagateCxfToCamel(endpoint.getHeaderFilterStrategy(),
exchange.getInMessage(),
+
+
CxfHeaderHelper.propagateCxfToCamel(endpoint.getHeaderFilterStrategy(),
exchange.getInMessage(),
cxfExchange.getIn().getHeaders());
cxfExchange.getIn().setBody(params);
try {
Added:
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfNonWrapperTest.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfNonWrapperTest.java?rev=686705&view=auto
==============================================================================
---
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfNonWrapperTest.java
(added)
+++
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfNonWrapperTest.java
Mon Aug 18 02:19:42 2008
@@ -0,0 +1,65 @@
+/**
+ * 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.net.URL;
+
+import javax.xml.namespace.QName;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.non_wrapper.Person;
+import org.apache.camel.non_wrapper.PersonService;
+import org.apache.camel.non_wrapper.UnknownPersonFault;
+import org.apache.camel.non_wrapper.types.GetPerson;
+import org.apache.camel.non_wrapper.types.GetPersonResponse;
+import org.apache.camel.spring.SpringTestSupport;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class CxfNonWrapperTest extends SpringTestSupport {
+
+ protected ClassPathXmlApplicationContext createApplicationContext() {
+ return new
ClassPathXmlApplicationContext("org/apache/camel/component/cxf/nonWrapperProcessor.xml");
+ }
+
+ protected void assertValidContext(CamelContext context) {
+ assertNotNull("No context found!", context);
+ }
+
+
+ public void testInvokingServiceFromCXFClient() throws Exception {
+
+ URL wsdlURL =
getClass().getClassLoader().getResource("person-non-wrapper.wsdl");
+ PersonService ss = new PersonService(wsdlURL, new
QName("http://camel.apache.org/non-wrapper", "PersonService"));
+ Person client = ss.getSoap();
+ GetPerson request = new GetPerson();
+ request.setPersonId("hello");
+ GetPersonResponse response = client.getPerson(request);
+
+ assertEquals("we should get the right answer from router", "Bonjour",
response.getName());
+
+ request.setPersonId("");
+ try {
+ client.getPerson(request);
+ fail("We expect to get the UnknowPersonFault here");
+ } catch (UnknownPersonFault fault) {
+ // We expect to get fault here
+ }
+ }
+
+
+
+}
Propchange:
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfNonWrapperTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfNonWrapperTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/non_wrapper/PersonProcessor.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/non_wrapper/PersonProcessor.java?rev=686705&view=auto
==============================================================================
---
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/non_wrapper/PersonProcessor.java
(added)
+++
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/non_wrapper/PersonProcessor.java
Mon Aug 18 02:19:42 2008
@@ -0,0 +1,68 @@
+/**
+ * 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.non_wrapper;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.non_wrapper.types.GetPerson;
+import org.apache.camel.non_wrapper.types.GetPersonResponse;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.cxf.message.MessageContentsList;
+import org.apache.cxf.service.model.BindingOperationInfo;
+
+// START SNIPPET: personProcessor
+public class PersonProcessor implements Processor {
+
+ private static final transient Log LOG =
LogFactory.getLog(PersonProcessor.class);
+
+ public void process(Exchange exchange) throws Exception {
+ LOG.info("processing exchange in camel");
+
+ BindingOperationInfo boi =
(BindingOperationInfo)exchange.getProperty(BindingOperationInfo.class.toString());
+ if (boi != null) {
+ LOG.info("boi.isUnwrapped" + boi.isUnwrapped());
+ }
+ // Get the parameters list which element is the holder.
+ MessageContentsList msgList =
(MessageContentsList)exchange.getIn().getBody();
+ GetPerson person = (GetPerson) msgList.get(0);
+ String personId = person.getPersonId();
+ GetPersonResponse response = new GetPersonResponse();
+
+ if (personId == null || personId.length() == 0) {
+ LOG.info("person id 123, so throwing exception");
+ // Try to throw out the soap fault message
+ org.apache.camel.non_wrapper.types.UnknownPersonFault personFault =
+ new org.apache.camel.non_wrapper.types.UnknownPersonFault();
+ personFault.setPersonId("");
+ org.apache.camel.non_wrapper.UnknownPersonFault fault =
+ new org.apache.camel.non_wrapper.UnknownPersonFault("Get the
null value of person name", personFault);
+ // Since camel has its own exception handler framework, we can't
throw the exception to trigger it
+ // We just set the fault message in the exchange for camel-cxf
component handling
+ exchange.getFault().setBody(fault);
+ }
+ response.setPersonId(personId);
+ response.setName("Bonjour");
+ response.setSsn("123");
+ LOG.info("setting Bonjour as the response");
+ // Set the response message, first element is the return value of the
operation,
+ // the others are the holders of method parameters
+ exchange.getOut().setBody(new Object[] {response});
+ }
+
+}
+// END SNIPPET: personProcessor
Propchange:
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/non_wrapper/PersonProcessor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/non_wrapper/PersonProcessor.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified:
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/wsdl_first/PersonProcessor.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/wsdl_first/PersonProcessor.java?rev=686705&r1=686704&r2=686705&view=diff
==============================================================================
---
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/wsdl_first/PersonProcessor.java
(original)
+++
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/wsdl_first/PersonProcessor.java
Mon Aug 18 02:19:42 2008
@@ -24,6 +24,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.cxf.message.MessageContentsList;
+import org.apache.cxf.service.model.BindingOperationInfo;
// START SNIPPET: personProcessor
public class PersonProcessor implements Processor {
@@ -32,6 +33,11 @@
public void process(Exchange exchange) throws Exception {
LOG.info("processing exchange in camel");
+
+ BindingOperationInfo boi =
(BindingOperationInfo)exchange.getProperty(BindingOperationInfo.class.toString());
+ if (boi != null) {
+ LOG.info("boi.isUnwrapped" + boi.isUnwrapped());
+ }
// Get the parameters list which element is the holder.
MessageContentsList msgList =
(MessageContentsList)exchange.getIn().getBody();
Holder<String> personId = (Holder<String>)msgList.get(0);
Added:
activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/nonWrapperProcessor.xml
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/nonWrapperProcessor.xml?rev=686705&view=auto
==============================================================================
---
activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/nonWrapperProcessor.xml
(added)
+++
activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/nonWrapperProcessor.xml
Mon Aug 18 02:19:42 2008
@@ -0,0 +1,46 @@
+<?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://activemq.apache.org/camel/schema/cxfEndpoint"
+ xmlns:camel="http://activemq.apache.org/camel/schema/spring"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+ http://activemq.apache.org/camel/schema/cxfEndpoint
http://activemq.apache.org/camel/schema/cxf/cxfEndpoint.xsd
+ http://activemq.apache.org/camel/schema/spring
http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
+ ">
+
+
+ <cxf:cxfEndpoint id="routerEndpoint"
address="http://localhost:8092/PersonService/"
+ serviceClass="org.apache.camel.non_wrapper.Person"
+ endpointName="person:soap"
+ serviceName="person:PersonService"
+ xmlns:person="http://camel.apache.org/non-wrapper"/>
+
+ <bean id="personProcessor"
class="org.apache.camel.non_wrapper.PersonProcessor"/>
+
+ <camelContext xmlns="http://activemq.apache.org/camel/schema/spring">
+ <route>
+ <from uri="cxf:bean:routerEndpoint?dataFormat=POJO"/>
+ <process ref= "personProcessor"/>
+ </route>
+
+ </camelContext>
+
+
+</beans>
Propchange:
activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/nonWrapperProcessor.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/nonWrapperProcessor.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange:
activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/nonWrapperProcessor.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added:
activemq/camel/trunk/components/camel-cxf/src/test/resources/person-non-wrapper.wsdl
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/test/resources/person-non-wrapper.wsdl?rev=686705&view=auto
==============================================================================
---
activemq/camel/trunk/components/camel-cxf/src/test/resources/person-non-wrapper.wsdl
(added)
+++
activemq/camel/trunk/components/camel-cxf/src/test/resources/person-non-wrapper.wsdl
Mon Aug 18 02:19:42 2008
@@ -0,0 +1,102 @@
+<?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.
+
+-->
+<!-- $Rev$ $Date$ -->
+<wsdl:definitions name="non-wrapper"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:tns="http://camel.apache.org/non-wrapper"
+ xmlns:typens="http://camel.apache.org/non-wrapper/types"
+ xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
+ targetNamespace="http://camel.apache.org/non-wrapper">
+
+ <wsdl:types>
+ <xsd:schema
targetNamespace="http://camel.apache.org/non-wrapper/types"
+ elementFormDefault="qualified">
+ <xsd:element name="GetPerson">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="personId"
type="xsd:string"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="GetPersonResponse">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="personId"
type="xsd:string"/>
+ <xsd:element name="ssn"
type="xsd:string"/>
+ <xsd:element name="name"
type="xsd:string"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="UnknownPersonFault">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="personId"
type="xsd:string"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ </wsdl:types>
+
+ <wsdl:message name="GetPersonRequest">
+ <wsdl:part name="payload" element="typens:GetPerson"/>
+ </wsdl:message>
+ <wsdl:message name="GetPersonResponse">
+ <wsdl:part name="payload" element="typens:GetPersonResponse"/>
+ </wsdl:message>
+ <wsdl:message name="UnknownPersonFault">
+ <wsdl:part name="payload" element="typens:UnknownPersonFault"/>
+ </wsdl:message>
+
+ <wsdl:portType name="Person">
+ <wsdl:operation name="GetPerson">
+ <wsdl:input message="tns:GetPersonRequest"/>
+ <wsdl:output message="tns:GetPersonResponse"/>
+ <wsdl:fault name="UnknownPerson"
message="tns:UnknownPersonFault"/>
+ </wsdl:operation>
+ <jaxws:bindings>
+ <jaxws:enableWrapperStyle>false</jaxws:enableWrapperStyle>
+ </jaxws:bindings>
+ </wsdl:portType>
+
+ <wsdl:binding name="PersonSOAPBinding" type="tns:Person">
+ <soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http" />
+ <wsdl:operation name="GetPerson">
+ <wsdl:input>
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" />
+ </wsdl:output>
+ <wsdl:fault name="UnknownPerson">
+ <soap:fault use="literal" name="UnknownPerson"
/>
+ </wsdl:fault>
+ </wsdl:operation>
+ </wsdl:binding>
+
+ <wsdl:service name="PersonService">
+ <wsdl:port binding="tns:PersonSOAPBinding" name="soap">
+ <soap:address location="http://localhost:8092/PersonService/" />
+ </wsdl:port>
+ </wsdl:service>
+
+</wsdl:definitions>
Propchange:
activemq/camel/trunk/components/camel-cxf/src/test/resources/person-non-wrapper.wsdl
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
activemq/camel/trunk/components/camel-cxf/src/test/resources/person-non-wrapper.wsdl
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange:
activemq/camel/trunk/components/camel-cxf/src/test/resources/person-non-wrapper.wsdl
------------------------------------------------------------------------------
svn:mime-type = text/xml