You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by ff...@apache.org on 2008/06/02 08:41:30 UTC

svn commit: r662340 - in /servicemix/smx4/features/trunk/camel/servicemix-camel: ./ src/main/java/org/apache/servicemix/camel/ src/test/java/org/apache/servicemix/camel/ src/test/java/org/apache/servicemix/samples/ src/test/java/org/apache/servicemix/s...

Author: ffang
Date: Sun Jun  1 23:41:29 2008
New Revision: 662340

URL: http://svn.apache.org/viewvc?rev=662340&view=rev
Log:
[SMX4-22]verify MESSAGE dataFormat of camel-cxf can work with servicemix-camel

Added:
    servicemix/smx4/features/trunk/camel/servicemix-camel/src/test/java/org/apache/servicemix/camel/CxfMessageTest.java   (with props)
    servicemix/smx4/features/trunk/camel/servicemix-camel/src/test/java/org/apache/servicemix/samples/
    servicemix/smx4/features/trunk/camel/servicemix-camel/src/test/java/org/apache/servicemix/samples/wsdl_first/
    servicemix/smx4/features/trunk/camel/servicemix-camel/src/test/java/org/apache/servicemix/samples/wsdl_first/PersonImpl.java   (with props)
    servicemix/smx4/features/trunk/camel/servicemix-camel/src/test/resources/org/apache/servicemix/camel/spring/CxfMessageBeans.xml   (with props)
    servicemix/smx4/features/trunk/camel/servicemix-camel/src/test/resources/person.wsdl   (with props)
Modified:
    servicemix/smx4/features/trunk/camel/servicemix-camel/pom.xml
    servicemix/smx4/features/trunk/camel/servicemix-camel/src/main/java/org/apache/servicemix/camel/ServiceMixConsumer.java

Modified: servicemix/smx4/features/trunk/camel/servicemix-camel/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/camel/servicemix-camel/pom.xml?rev=662340&r1=662339&r2=662340&view=diff
==============================================================================
--- servicemix/smx4/features/trunk/camel/servicemix-camel/pom.xml (original)
+++ servicemix/smx4/features/trunk/camel/servicemix-camel/pom.xml Sun Jun  1 23:41:29 2008
@@ -67,6 +67,44 @@
             <groupId>org.apache.camel</groupId>
             <artifactId>camel-cxf</artifactId>
             <version>${camel.version}</version>
+            <exclusions> 
+                <exclusion>
+                    <groupId>org.apache.cxf</groupId>
+                    <artifactId>cxf-rt-core</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.apache.cxf</groupId>
+                    <artifactId>cxf-rt-transports-http</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.apache.cxf</groupId>
+                    <artifactId>cxf-rt-transports-http-jetty</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.apache.cxf</groupId>
+                    <artifactId>cxf-rt-transports-local</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.apache.cxf</groupId>
+                    <artifactId>cxf-rt-frontend-simple</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.apache.cxf</groupId>
+                    <artifactId>cxf-rt-frontend-jaxws</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.apache.cxf</groupId>
+                    <artifactId>cxf-rt-management</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.apache.cxf</groupId>
+                    <artifactId>cxf-testutils</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.apache.cxf</groupId>
+                    <artifactId>cxf-tools-common</artifactId>
+                </exclusion>
+            </exclusions>
         </dependency>
         <dependency>
             <groupId>org.apache.camel</groupId>
@@ -159,6 +197,31 @@
                     </systemProperties>
                 </configuration>
             </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: servicemix/smx4/features/trunk/camel/servicemix-camel/src/main/java/org/apache/servicemix/camel/ServiceMixConsumer.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/camel/servicemix-camel/src/main/java/org/apache/servicemix/camel/ServiceMixConsumer.java?rev=662340&r1=662339&r2=662340&view=diff
==============================================================================
--- servicemix/smx4/features/trunk/camel/servicemix-camel/src/main/java/org/apache/servicemix/camel/ServiceMixConsumer.java (original)
+++ servicemix/smx4/features/trunk/camel/servicemix-camel/src/main/java/org/apache/servicemix/camel/ServiceMixConsumer.java Sun Jun  1 23:41:29 2008
@@ -64,12 +64,19 @@
             	ServiceMixExchange smExchange = getEndpoint().createExchange(exchange.getIn(), exchange);
             	smExchange.setPattern(ExchangePattern.fromWsdlUri(exchange.getPattern().getWsdlUri()));
                 getAsyncProcessor().process(smExchange);
-                if (smExchange.getFault(false) != null) {
+                /*if (smExchange.getFault(false) != null) {
                     exchange.getFault().setBody(smExchange.getFault().getBody());
                 } else if (smExchange.getOut(false) != null) {
                     exchange.getOut().setBody(smExchange.getOut().getBody());
                 } else {
                     exchange.setStatus(Status.Done);
+                }*/
+                if (smExchange.getOut(false) != null) {
+                    exchange.getOut().setBody(smExchange.getOut().getBody());
+                } else if (smExchange.getFault(false) != null) {
+                    exchange.getFault().setBody(smExchange.getFault().getBody());
+                } else {
+                    exchange.setStatus(Status.Done);
                 }
                 channel.send(exchange);
             } catch (Exception e) {

Added: servicemix/smx4/features/trunk/camel/servicemix-camel/src/test/java/org/apache/servicemix/camel/CxfMessageTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/camel/servicemix-camel/src/test/java/org/apache/servicemix/camel/CxfMessageTest.java?rev=662340&view=auto
==============================================================================
--- servicemix/smx4/features/trunk/camel/servicemix-camel/src/test/java/org/apache/servicemix/camel/CxfMessageTest.java (added)
+++ servicemix/smx4/features/trunk/camel/servicemix-camel/src/test/java/org/apache/servicemix/camel/CxfMessageTest.java Sun Jun  1 23:41:29 2008
@@ -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.servicemix.camel;
+
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Endpoint;
+import javax.xml.ws.Holder;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.spring.SpringTestSupport;
+import org.apache.camel.CamelContext;
+import org.apache.cxf.endpoint.ServerImpl;
+import org.apache.cxf.frontend.ClientProxy;
+import org.apache.cxf.interceptor.LoggingInInterceptor;
+import org.apache.cxf.interceptor.LoggingOutInterceptor;
+import org.apache.servicemix.samples.wsdl_first.Person;
+import org.apache.servicemix.samples.wsdl_first.PersonImpl;
+import org.apache.servicemix.samples.wsdl_first.PersonService;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+
+public class CxfMessageTest extends SpringTestSupport {
+       
+    
+    private ServerImpl server;
+
+    
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();        
+                
+        startService();
+    }
+
+    protected ClassPathXmlApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/servicemix/camel/spring/CxfMessageBeans.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() {
+            	//from(routerEndpointURI).to("smx:testEndpoint");// like what do in binding component
+            	//from("smx:testEndpoint").to(serviceEndpointURI);// like what do in se
+            }
+        };
+    }
+    
+    public void testInvokingServiceFromCXFClient() throws Exception {  
+     
+    	URL wsdlURL = getClass().getClassLoader().getResource("person.wsdl");
+        
+
+        System.out.println(wsdlURL);
+        PersonService ss = new PersonService(wsdlURL, new QName("http://servicemix.apache.org/samples/wsdl-first", 
+			"PersonService"));
+        Person client = ss.getSoap();
+        ClientProxy.getClient(client).getOutInterceptors().add(new LoggingOutInterceptor());
+        ClientProxy.getClient(client).getInInterceptors().add(new LoggingInInterceptor());
+        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);
+    }
+    
+        
+    
+}
\ No newline at end of file

Propchange: servicemix/smx4/features/trunk/camel/servicemix-camel/src/test/java/org/apache/servicemix/camel/CxfMessageTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: servicemix/smx4/features/trunk/camel/servicemix-camel/src/test/java/org/apache/servicemix/camel/CxfMessageTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: servicemix/smx4/features/trunk/camel/servicemix-camel/src/test/java/org/apache/servicemix/samples/wsdl_first/PersonImpl.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/camel/servicemix-camel/src/test/java/org/apache/servicemix/samples/wsdl_first/PersonImpl.java?rev=662340&view=auto
==============================================================================
--- servicemix/smx4/features/trunk/camel/servicemix-camel/src/test/java/org/apache/servicemix/samples/wsdl_first/PersonImpl.java (added)
+++ servicemix/smx4/features/trunk/camel/servicemix-camel/src/test/java/org/apache/servicemix/samples/wsdl_first/PersonImpl.java Sun Jun  1 23:41:29 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.servicemix.samples.wsdl_first;
+
+import javax.jws.WebService;
+import javax.xml.ws.Holder;
+
+@WebService(serviceName = "PersonService",
+        targetNamespace = "http://servicemix.apache.org/samples/wsdl-first",
+        endpointInterface = "org.apache.servicemix.samples.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.servicemix.samples.wsdl_first.types.UnknownPersonFault
+                fault = new org.apache.servicemix.samples.wsdl_first.types.UnknownPersonFault();
+            fault.setPersonId(personId.value);
+            throw new UnknownPersonFault(null, fault);
+        }
+        name.value = "Bonjour";
+        ssn.value = "000-000-0000";
+    }
+
+}

Propchange: servicemix/smx4/features/trunk/camel/servicemix-camel/src/test/java/org/apache/servicemix/samples/wsdl_first/PersonImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: servicemix/smx4/features/trunk/camel/servicemix-camel/src/test/java/org/apache/servicemix/samples/wsdl_first/PersonImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: servicemix/smx4/features/trunk/camel/servicemix-camel/src/test/resources/org/apache/servicemix/camel/spring/CxfMessageBeans.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/camel/servicemix-camel/src/test/resources/org/apache/servicemix/camel/spring/CxfMessageBeans.xml?rev=662340&view=auto
==============================================================================
--- servicemix/smx4/features/trunk/camel/servicemix-camel/src/test/resources/org/apache/servicemix/camel/spring/CxfMessageBeans.xml (added)
+++ servicemix/smx4/features/trunk/camel/servicemix-camel/src/test/resources/org/apache/servicemix/camel/spring/CxfMessageBeans.xml Sun Jun  1 23:41:29 2008
@@ -0,0 +1,57 @@
+<?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:8192/PersonService/" 
+                   serviceClass="org.apache.servicemix.samples.wsdl_first.Person"
+                   endpointName="person:soap"
+                   serviceName="person:PersonService"
+                   xmlns:person="http://servicemix.apache.org/samples/wsdl-first"/>
+  
+    
+  <cxf:cxfEndpoint id="serviceEndpoint" address="http://localhost:9000/PersonService/" 
+                   serviceClass="org.apache.servicemix.samples.wsdl_first.Person"
+                   endpointName="person:soap"
+                   serviceName="person:PersonService"
+                   xmlns:person="http://servicemix.apache.org/samples/wsdl-first"/>
+
+   <camelContext xmlns="http://activemq.apache.org/camel/schema/spring">
+      <route>
+            <from uri="cxf:bean:routerEndpoint?dataFormat=MESSAGE"/>
+            <to uri="smx:bean:testEndpoint"/>
+      </route>
+
+      <route>
+            <from uri="smx:bean:testEndpoint"/>
+            <to uri="cxf:bean:serviceEndpoint?dataFormat=MESSAGE"/>
+      </route>
+
+    </camelContext>
+
+  <bean id="org.apache.servicemix.nmr.api.NMR" class="org.apache.servicemix.nmr.core.ServiceMix" init-method="init" />
+
+</beans>

Propchange: servicemix/smx4/features/trunk/camel/servicemix-camel/src/test/resources/org/apache/servicemix/camel/spring/CxfMessageBeans.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: servicemix/smx4/features/trunk/camel/servicemix-camel/src/test/resources/org/apache/servicemix/camel/spring/CxfMessageBeans.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: servicemix/smx4/features/trunk/camel/servicemix-camel/src/test/resources/org/apache/servicemix/camel/spring/CxfMessageBeans.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: servicemix/smx4/features/trunk/camel/servicemix-camel/src/test/resources/person.wsdl
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/camel/servicemix-camel/src/test/resources/person.wsdl?rev=662340&view=auto
==============================================================================
--- servicemix/smx4/features/trunk/camel/servicemix-camel/src/test/resources/person.wsdl (added)
+++ servicemix/smx4/features/trunk/camel/servicemix-camel/src/test/resources/person.wsdl Sun Jun  1 23:41:29 2008
@@ -0,0 +1,97 @@
+<?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.
+
+-->
+<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://servicemix.apache.org/samples/wsdl-first"
+	xmlns:typens="http://servicemix.apache.org/samples/wsdl-first/types"
+	targetNamespace="http://servicemix.apache.org/samples/wsdl-first">
+
+	<wsdl:types>
+		<xsd:schema targetNamespace="http://servicemix.apache.org/samples/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:8192/PersonService/" />
+       </wsdl:port>
+   </wsdl:service>
+
+</wsdl:definitions>

Propchange: servicemix/smx4/features/trunk/camel/servicemix-camel/src/test/resources/person.wsdl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: servicemix/smx4/features/trunk/camel/servicemix-camel/src/test/resources/person.wsdl
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: servicemix/smx4/features/trunk/camel/servicemix-camel/src/test/resources/person.wsdl
------------------------------------------------------------------------------
    svn:mime-type = text/xml