Author: ningjiang
Date: Sun Jun  1 07:41:53 2008
New Revision: 662226

URL: http://svn.apache.org/viewvc?rev=662226&view=rev
Log:
CAMEL-566 patch applied with thanks to Freeman

Added:
    
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfWsdlFirstTest.java
   (with props)
    
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/wsdl_first/
    
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/wsdl_first/PersonImpl.java
   (with props)
    
activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/WsdlFirstBeans.xml
   (with props)
    activemq/camel/trunk/components/camel-cxf/src/test/resources/person.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

Modified: activemq/camel/trunk/components/camel-cxf/pom.xml
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/pom.xml?rev=662226&r1=662225&r2=662226&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/pom.xml (original)
+++ activemq/camel/trunk/components/camel-cxf/pom.xml Sun Jun  1 07:41:53 2008
@@ -155,7 +155,7 @@
       </exclusions>
     </dependency>
     <dependency>
-      <groupId>javax.xml</groupId>
+      <groupId>javax.xml.bind</groupId>
       <artifactId>jaxb-api</artifactId>
       <version>${jaxb-api-version}</version>
       <exclusions>
@@ -268,6 +268,31 @@
           </execution>
         </executions>
       </plugin>
+      <plugin>
+       <groupId>org.apache.cxf</groupId>
+       <artifactId>cxf-codegen-plugin</artifactId>
+       <version>${cxf-version}</version>
+       <executions>
+               <execution>
+                       <id>generate-test-sources</id>
+                       <phase>generate-sources</phase>
+                       <configuration>
+                               
<sourceRoot>${basedir}/target/generated</sourceRoot>
+                               <wsdlOptions>
+                                       <wsdlOption>
+                                               
<wsdl>${basedir}/src/test/resources/person.wsdl</wsdl>
+                                               <extraargs>
+                                                       
<extraarg>-verbose</extraarg>
+                                               </extraargs>
+                                       </wsdlOption>
+                               </wsdlOptions>
+                       </configuration>
+                       <goals>
+                               <goal>wsdl2java</goal>
+                       </goals>
+               </execution>
+       </executions>
+      </plugin>
     </plugins>
   </build>
 

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=662226&r1=662225&r2=662226&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
 Sun Jun  1 07:41:53 2008
@@ -146,7 +146,11 @@
         } else {
             cxfExchange.setPattern(ExchangePattern.InOut);
         }
-        cxfExchange.getIn().setHeader(CxfConstants.OPERATION_NAME, 
m.getName());
+        if (bop != null && bop.getName() != null) {
+               cxfExchange.getIn().setHeader(CxfConstants.OPERATION_NAME, 
bop.getName().getLocalPart());
+        } else {
+               cxfExchange.getIn().setHeader(CxfConstants.OPERATION_NAME, 
m.getName());
+        }
         cxfExchange.getIn().setBody(params);
         try {
             cxfConsumer.getProcessor().process(cxfExchange);

Added: 
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfWsdlFirstTest.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfWsdlFirstTest.java?rev=662226&view=auto
==============================================================================
--- 
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfWsdlFirstTest.java
 (added)
+++ 
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfWsdlFirstTest.java
 Sun Jun  1 07:41:53 2008
@@ -0,0 +1,95 @@
+/**
+ * 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 javax.xml.ws.Endpoint;
+import javax.xml.ws.Holder;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.spring.SpringTestSupport;
+import org.apache.camel.wsdl_first.Person;
+import org.apache.camel.wsdl_first.PersonImpl;
+import org.apache.camel.wsdl_first.PersonService;
+import org.apache.cxf.endpoint.ServerImpl;
+import org.apache.cxf.frontend.ClientProxy;
+import org.apache.cxf.interceptor.LoggingOutInterceptor;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class CxfWsdlFirstTest extends SpringTestSupport {
+
+
+    private ServerImpl server;
+
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        startService();
+    }
+
+    protected ClassPathXmlApplicationContext createApplicationContext() {
+        return new 
ClassPathXmlApplicationContext("org/apache/camel/component/cxf/WsdlFirstBeans.xml");
+    }
+
+    protected void assertValidContext(CamelContext context) {
+        assertNotNull("No context found!", context);
+    }
+
+    protected void startService() {
+       Object implementor = new PersonImpl();
+        String address = "http://localhost:9000/PersonService/";;
+        Endpoint.publish(address, implementor);
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        if (server != null) {
+            server.stop();
+        }
+        super.tearDown();
+    }
+
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            public void configure() {
+            }
+        };
+    }
+
+    public void testInvokingServiceFromCXFClient() throws Exception {
+
+       URL wsdlURL = getClass().getClassLoader().getResource("person.wsdl");
+        PersonService ss = new PersonService(wsdlURL, new 
QName("http://camel.apache.org/wsdl-first";,
+                       "PersonService"));
+        Person client = ss.getSoap();
+        ClientProxy.getClient(client).getOutInterceptors().add(new 
LoggingOutInterceptor());
+        Holder<String> personId = new Holder<String>();
+        personId.value = "world";
+        Holder<String> ssn = new Holder<String>();
+        Holder<String> name = new Holder<String>();
+        client.getPerson(personId, ssn, name);
+        assertEquals("we should get the right answer from router", "Bonjour", 
name.value);
+    }
+
+
+
+}

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

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

Added: 
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/wsdl_first/PersonImpl.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/wsdl_first/PersonImpl.java?rev=662226&view=auto
==============================================================================
--- 
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/wsdl_first/PersonImpl.java
 (added)
+++ 
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/wsdl_first/PersonImpl.java
 Sun Jun  1 07:41:53 2008
@@ -0,0 +1,40 @@
+/**
+ * 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.wsdl_first;
+
+import javax.jws.WebService;
+import javax.xml.ws.Holder;
+
[EMAIL PROTECTED](serviceName = "PersonService",
+        targetNamespace = "http://camel.apache.org/wsdl-first";,
+        endpointInterface = "org.apache.camel.wsdl_first.Person")
+public class PersonImpl implements Person {
+
+    public void getPerson(Holder<String> personId, Holder<String> ssn,
+            Holder<String> name) throws UnknownPersonFault {
+        System.out.println("the server is invoked ");
+        if (personId.value == null || personId.value.length() == 0) {
+            org.apache.camel.wsdl_first.types.UnknownPersonFault
+                fault = new 
org.apache.camel.wsdl_first.types.UnknownPersonFault();
+            fault.setPersonId(personId.value);
+            throw new UnknownPersonFault(null, fault);
+        }
+        name.value = "Bonjour";
+        ssn.value = "000-000-0000";
+    }
+
+}

Propchange: 
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/wsdl_first/PersonImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/wsdl_first/PersonImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: 
activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/WsdlFirstBeans.xml
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/WsdlFirstBeans.xml?rev=662226&view=auto
==============================================================================
--- 
activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/WsdlFirstBeans.xml
 (added)
+++ 
activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/WsdlFirstBeans.xml
 Sun Jun  1 07:41:53 2008
@@ -0,0 +1,51 @@
+<?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.wsdl_first.Person"
+                   endpointName="person:soap"
+                   serviceName="person:PersonService"
+                   xmlns:person="http://camel.apache.org/wsdl-first"/>
+  
+    
+  <cxf:cxfEndpoint id="serviceEndpoint" 
address="http://localhost:9000/PersonService/"; 
+                   serviceClass="org.apache.camel.wsdl_first.Person"
+                   endpointName="person:soap"
+                   serviceName="person:PersonService"
+                   xmlns:person="http://camel.apache.org/wsdl-first"/>
+
+   <camelContext xmlns="http://activemq.apache.org/camel/schema/spring";>
+      <route>
+            <from uri="cxf:bean:routerEndpoint?dataFormat=MESSAGE"/>
+            <to uri="cxf:bean:serviceEndpoint?dataFormat=MESSAGE"/>
+      </route>
+
+    </camelContext>
+
+
+</beans>

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

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

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

Added: activemq/camel/trunk/components/camel-cxf/src/test/resources/person.wsdl
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/test/resources/person.wsdl?rev=662226&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/test/resources/person.wsdl 
(added)
+++ activemq/camel/trunk/components/camel-cxf/src/test/resources/person.wsdl 
Sun Jun  1 07:41:53 2008
@@ -0,0 +1,98 @@
+<?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="wsdl-first"
+       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/wsdl-first";
+       xmlns:typens="http://camel.apache.org/wsdl-first/types";
+       targetNamespace="http://camel.apache.org/wsdl-first";>
+
+       <wsdl:types>
+               <xsd:schema 
targetNamespace="http://camel.apache.org/wsdl-first/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>
+       </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.wsdl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
activemq/camel/trunk/components/camel-cxf/src/test/resources/person.wsdl
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: 
activemq/camel/trunk/components/camel-cxf/src/test/resources/person.wsdl
------------------------------------------------------------------------------
    svn:mime-type = text/xml


Reply via email to