Author: ningjiang
Date: Wed Aug  3 02:59:30 2011
New Revision: 1153323

URL: http://svn.apache.org/viewvc?rev=1153323&view=rev
Log:
CAMEL-4294 Fixed the WSDL generation issue of Camel 2.8.0

Added:
    
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/wsdl/
    
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/wsdl/Order.java
   (with props)
    
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/wsdl/OrderEndpoint.java
   (with props)
    
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/wsdl/OrderTest.java
   (with props)
    
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/wsdl/
    
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/wsdl/camel-cxf.xml
   (with props)
    
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/wsdl/camel-route.xml
   (with props)
Modified:
    
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java

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=1153323&r1=1153322&r2=1153323&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 Aug  3 02:59:30 2011
@@ -120,7 +120,7 @@ public class CxfEndpoint extends Default
         = new ModCountCopyOnWriteArrayList<AbstractFeature>();
 
     private List<Handler> handlers;
-    private List<String> schemaLocations = new ArrayList<String>();
+    private List<String> schemaLocations;
     private String transportId;
     private String bindingId;
 
@@ -182,13 +182,19 @@ public class CxfEndpoint extends Default
         sfb.setOutFaultInterceptors(outFault);
         sfb.setInFaultInterceptors(inFault); 
         sfb.setFeatures(features);
-        sfb.setSchemaLocations(schemaLocations);
+        if (schemaLocations != null) {
+            sfb.setSchemaLocations(schemaLocations);
+        }
         
         if (sfb instanceof JaxWsServerFactoryBean && handlers != null) {
             ((JaxWsServerFactoryBean)sfb).setHandlers(handlers);
         }
-        sfb.setTransportId(transportId);
-        sfb.setBindingId(bindingId);
+        if (transportId != null) {
+            sfb.setTransportId(transportId);
+        }
+        if (bindingId != null) {
+            sfb.setBindingId(bindingId);
+        }
         
         // wsdl url
         if (getWsdlURL() != null) {
@@ -312,9 +318,13 @@ public class CxfEndpoint extends Default
         
         if (factoryBean instanceof JaxWsProxyFactoryBean && handlers != null) {
             ((JaxWsProxyFactoryBean)factoryBean).setHandlers(handlers);
-        }        
-        factoryBean.setTransportId(transportId);
-        factoryBean.setBindingId(bindingId);
+        }
+        if (transportId != null) {
+            factoryBean.setTransportId(transportId);
+        }
+        if (bindingId != null) {
+            factoryBean.setBindingId(bindingId);
+        }
 
         // address
         factoryBean.setAddress(getAddress());

Added: 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/wsdl/Order.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/wsdl/Order.java?rev=1153323&view=auto
==============================================================================
--- 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/wsdl/Order.java
 (added)
+++ 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/wsdl/Order.java
 Wed Aug  3 02:59:30 2011
@@ -0,0 +1,47 @@
+/**
+ * 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.wsdl;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+public class Order {
+
+    String customerName;
+    String productName;
+
+    public String getCustomerName() {
+        return customerName;
+    }
+
+    public void setCustomerName(String customerName) {
+        this.customerName = customerName;
+    }
+
+    public String getProductName() {
+        return productName;
+    }
+
+    public void setProductName(String productName) {
+        this.productName = productName;
+    }
+
+    @Override
+    public String toString() {
+        return "order[" + customerName + "," + productName + "]";
+    }
+
+}

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

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

Added: 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/wsdl/OrderEndpoint.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/wsdl/OrderEndpoint.java?rev=1153323&view=auto
==============================================================================
--- 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/wsdl/OrderEndpoint.java
 (added)
+++ 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/wsdl/OrderEndpoint.java
 Wed Aug  3 02:59:30 2011
@@ -0,0 +1,30 @@
+/**
+ * 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.wsdl;
+
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+
+@WebService
+public class OrderEndpoint {
+
+    @WebMethod
+    public String doOrder(Order order) {
+        System.out.println("Processing order");
+        return "Order processed " + order;
+    };
+}

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

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

Added: 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/wsdl/OrderTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/wsdl/OrderTest.java?rev=1153323&view=auto
==============================================================================
--- 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/wsdl/OrderTest.java
 (added)
+++ 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/wsdl/OrderTest.java
 Wed Aug  3 02:59:30 2011
@@ -0,0 +1,66 @@
+/**
+ * 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.wsdl;
+
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.LineNumberReader;
+
+import org.apache.camel.ExchangePattern;
+import org.apache.camel.test.junit4.CamelSpringTestSupport;
+import org.junit.Test;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class OrderTest extends CamelSpringTestSupport {
+
+    @Override
+    protected AbstractXmlApplicationContext createApplicationContext() {
+        return new 
ClassPathXmlApplicationContext("org/apache/camel/component/cxf/wsdl/camel-route.xml");
+    }
+
+    @Test
+    public void testCamelWsdl() throws Exception {
+        Object body = template.sendBody("seda:camelWsdl", 
ExchangePattern.InOut, null);
+        checkWsdl(InputStream.class.cast(body));
+    }
+
+    @Test
+    public void testCxfWsdl() throws Exception {
+        Object body = template.sendBody("seda:cxfWsdl", ExchangePattern.InOut, 
null);
+        checkWsdl(InputStream.class.cast(body));
+    }
+
+    public void checkWsdl(InputStream in) throws Exception {
+
+        boolean containsOrderComplexType = false;
+        LineNumberReader reader = new LineNumberReader(new 
InputStreamReader(in));
+        String line;
+        while ((line = reader.readLine()) != null) {
+            if (line.contains("complexType name=\"order\"")) {
+                containsOrderComplexType = true;
+                // break;
+            }
+
+        }
+
+        if (!containsOrderComplexType) {
+            throw new RuntimeException("WSDL does not contain complex type 
defintion for class Order");
+        }
+
+    }
+}

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

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

Added: 
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/wsdl/camel-cxf.xml
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/wsdl/camel-cxf.xml?rev=1153323&view=auto
==============================================================================
--- 
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/wsdl/camel-cxf.xml
 (added)
+++ 
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/wsdl/camel-cxf.xml
 Wed Aug  3 02:59:30 2011
@@ -0,0 +1,35 @@
+<?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:jaxws="http://cxf.apache.org/jaxws";
+       xsi:schemaLocation="
+         http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+         http://camel.apache.org/schema/cxf 
http://camel.apache.org/schema/cxf/camel-cxf.xsd
+         http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd";>
+
+       <import resource="classpath:META-INF/cxf/cxf.xml" />
+
+       <!-- The camel CXF endpoint -->
+       <cxf:cxfEndpoint id="orderEndpoint" 
address="http://localhost:9000/camel-order/"; 
serviceClass="org.apache.camel.component.cxf.wsdl.OrderEndpoint" />
+
+       <!-- JAX-WS endpoint of the same class -->
+       <jaxws:endpoint id="orderEndpointCXF" 
address="http://localhost:9000/cxf-order/"; 
implementor="org.apache.camel.component.cxf.wsdl.OrderEndpoint" />
+       
+
+</beans>

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

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

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

Added: 
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/wsdl/camel-route.xml
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/wsdl/camel-route.xml?rev=1153323&view=auto
==============================================================================
--- 
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/wsdl/camel-route.xml
 (added)
+++ 
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/wsdl/camel-route.xml
 Wed Aug  3 02:59:30 2011
@@ -0,0 +1,48 @@
+<?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:camel="http://camel.apache.org/schema/spring";
+       xsi:schemaLocation="
+         http://www.springframework.org/schema/beans 
+         http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+         http://camel.apache.org/schema/spring 
+         http://camel.apache.org/schema/spring/camel-spring.xsd";>
+
+       <import 
resource="classpath:org/apache/camel/component/cxf/wsdl/camel-cxf.xml" />
+
+       <camelContext xmlns="http://camel.apache.org/schema/spring";>
+
+               <route>
+                       <!-- route starts from the cxf webservice, see 
camel-cxf.xml for details -->
+                       <from uri="cxf:bean:orderEndpoint" />
+                       <!-- and then create the OK reply for the webservice 
which is still waiting for a reply -->
+                       <transform>
+                               <constant>OK</constant>
+                       </transform>
+                       <to uri="mock:end" />
+               </route>
+
+               <!-- test route -->
+               <route>
+                       <from uri="seda:camelWsdl" />
+                       <to 
uri="http://localhost:9000/camel-order/services?wsdl"; />
+                       <log message="end route camelWsdl"/>
+               </route>
+               
+               <route>
+                       <from uri="seda:cxfWsdl" />
+                       <to uri="http://localhost:9000/cxf-order/services?wsdl"; 
/>
+                       <log message="endroute cxf wsdl"/>
+               </route>
+
+       </camelContext>
+
+
+</beans>

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

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

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


Reply via email to