Author: ningjiang
Date: Wed Jan 5 07:07:57 2011
New Revision: 1055323
URL: http://svn.apache.org/viewvc?rev=1055323&view=rev
Log:
CAMEL-3494 camel-cxf endpoint supports to lookup service name and endpoint name
from the wsdl if there is only one in the WSDL
Added:
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfPayLoadSoapHeaderSpringTest.java
(with props)
Modified:
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/CxfSpringEndpoint.java
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/WSDLServiceFactoryBean.java
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfPayLoadSoapHeaderTest.java
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerTest.java
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/PizzaEndpoints.xml
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=1055323&r1=1055322&r2=1055323&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 Jan 5 07:07:57 2011
@@ -360,9 +360,9 @@ public class CxfEndpoint extends Default
}
- void checkName(String value, String name) {
+ void checkName(Object value, String name) {
if (ObjectHelper.isEmpty(value)) {
- LOG.warn("The " + name + "is empty, cxf will try to load the first
one in wsdl for you");
+ LOG.warn("The " + name + " of " + this.getEndpointUri() + " is
empty, cxf will try to load the first one in wsdl for you.");
}
}
@@ -384,8 +384,8 @@ public class CxfEndpoint extends Default
ServerFactoryBean answer = null;
if (cls == null) {
- ObjectHelper.notNull(portName, "Please provide endpoint/port
name");
- ObjectHelper.notNull(serviceName, "Please provide service name");
+ checkName(portName, " endpoint/port name");
+ checkName(serviceName, " service name");
answer = new ServerFactoryBean(new WSDLServiceFactoryBean());
} else if (CxfEndpointUtils.hasWebServiceAnnotation(cls)) {
answer = new JaxWsServerFactoryBean();
Modified:
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSpringEndpoint.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSpringEndpoint.java?rev=1055323&r1=1055322&r2=1055323&view=diff
==============================================================================
---
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSpringEndpoint.java
(original)
+++
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSpringEndpoint.java
Wed Jan 5 07:07:57 2011
@@ -162,8 +162,8 @@ public class CxfSpringEndpoint extends C
factoryBean.setEndpointName(new QName(getEndpointNamespace(),
getEndpointLocalName()));
}
- ObjectHelper.notNull(factoryBean.getEndpointName(), "Please
provide endpoint/port name");
- ObjectHelper.notNull(factoryBean.getServiceName(), "Please provide
service name");
+ checkName(factoryBean.getEndpointName(), "endpoint/port name");
+ checkName(factoryBean.getServiceName(), "service name");
return (Client)factoryBean.create();
}
}
@@ -210,8 +210,8 @@ public class CxfSpringEndpoint extends C
}
if (cls == null) {
- ObjectHelper.notNull(answer.getEndpointName(), "Please provide
endpoint/port name");
- ObjectHelper.notNull(answer.getServiceName(), "Please provide
service name");
+ checkName(answer.getEndpointName(), "endpoint/port name");
+ checkName(answer.getServiceName(), "service name");
}
return answer;
}
Modified:
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/WSDLServiceFactoryBean.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/WSDLServiceFactoryBean.java?rev=1055323&r1=1055322&r2=1055323&view=diff
==============================================================================
---
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/WSDLServiceFactoryBean.java
(original)
+++
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/WSDLServiceFactoryBean.java
Wed Jan 5 07:07:57 2011
@@ -16,16 +16,29 @@
*/
package org.apache.camel.component.cxf;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.cxf.service.factory.AbstractServiceConfiguration;
import org.apache.cxf.service.factory.ReflectionServiceFactoryBean;
import org.apache.cxf.service.invoker.Invoker;
/**
* A service factory bean class that create a service factory without
requiring a service class
* (SEI).
- *
+ * It will pick the first one service name and first one port/endpoint name in
the WSDL, if
+ * there is service name or port/endpoint name setted.
* @version $Revision$
*/
public class WSDLServiceFactoryBean extends ReflectionServiceFactoryBean {
+
+ public WSDLServiceFactoryBean() {
+ // set up the service configure to help us find the service name and
endpoint name from WSDL
+ WSDLServiceConfiguration configuration = new
WSDLServiceConfiguration(this);
+ List<AbstractServiceConfiguration> list = new
ArrayList<AbstractServiceConfiguration>();
+ list.add(configuration);
+ this.setServiceConfigurations(list);
+ }
@Override
protected void initializeWSDLOperations() {
Added:
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfPayLoadSoapHeaderSpringTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfPayLoadSoapHeaderSpringTest.java?rev=1055323&view=auto
==============================================================================
---
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfPayLoadSoapHeaderSpringTest.java
(added)
+++
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfPayLoadSoapHeaderSpringTest.java
Wed Jan 5 07:07:57 2011
@@ -0,0 +1,83 @@
+/**
+ * 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 java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Endpoint;
+
+import org.w3c.dom.Element;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.pizza.Pizza;
+import org.apache.camel.pizza.PizzaService;
+import org.apache.camel.pizza.types.CallerIDHeaderType;
+import org.apache.camel.pizza.types.OrderPizzaResponseType;
+import org.apache.camel.pizza.types.OrderPizzaType;
+import org.apache.camel.pizza.types.ToppingsListType;
+import org.apache.camel.spring.SpringCamelContext;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.cxf.binding.soap.SoapHeader;
+import org.junit.After;
+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 CxfPayLoadSoapHeaderSpringTest extends CxfPayLoadSoapHeaderTest {
+ protected AbstractXmlApplicationContext applicationContext;
+
+ protected String getRouterEndpointURI() {
+ return "cxf:bean:routerEndpoint?dataFormat=PAYLOAD";
+ }
+ protected String getServiceEndpointURI() {
+ return "cxf:bean:serviceEndpoint?dataFormat=PAYLOAD";
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ applicationContext = createApplicationContext();
+ super.setUp();
+ assertNotNull("Should have created a valid spring context",
applicationContext);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ if (applicationContext != null) {
+ applicationContext.destroy();
+ }
+ super.tearDown();
+ }
+
+ @Override
+ protected CamelContext createCamelContext() throws Exception {
+ return SpringCamelContext.springCamelContext(applicationContext);
+ }
+
+ protected ClassPathXmlApplicationContext createApplicationContext() {
+ return new
ClassPathXmlApplicationContext("org/apache/camel/component/cxf/PizzaEndpoints.xml");
+ }
+
+
+
+}
Propchange:
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfPayLoadSoapHeaderSpringTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfPayLoadSoapHeaderSpringTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified:
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfPayLoadSoapHeaderTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfPayLoadSoapHeaderTest.java?rev=1055323&r1=1055322&r2=1055323&view=diff
==============================================================================
---
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfPayLoadSoapHeaderTest.java
(original)
+++
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfPayLoadSoapHeaderTest.java
Wed Jan 5 07:07:57 2011
@@ -45,20 +45,22 @@ import org.springframework.context.suppo
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class CxfPayLoadSoapHeaderTest extends CamelTestSupport {
- protected AbstractXmlApplicationContext applicationContext;
-
- protected String routerEndpointURI =
"cxf:bean:routerEndpoint?dataFormat=PAYLOAD";
- protected String serviceEndpointURI =
"cxf:bean:serviceEndpoint?dataFormat=PAYLOAD";
private final QName serviceName = new
QName("http://camel.apache.org/pizza", "PizzaService");
+ protected String getRouterEndpointURI() {
+ return
"cxf:http://localhost:9013/pizza_service/services/PizzaService?wsdlURL=classpath:pizza_service.wsdl&dataFormat=PAYLOAD";
+ }
+ protected String getServiceEndpointURI() {
+ return
"cxf:http://localhost:9023/new_pizza_service/services/PizzaService?wsdlURL=classpath:pizza_service.wsdl&dataFormat=PAYLOAD";
+ }
@Override
protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
public void configure() {
// START SNIPPET: payload
- from(routerEndpointURI).process(new Processor() {
+ from(getRouterEndpointURI()).process(new Processor() {
@SuppressWarnings("unchecked")
public void process(Exchange exchange) throws Exception {
CxfPayload<SoapHeader> payload =
exchange.getIn().getBody(CxfPayload.class);
@@ -77,26 +79,12 @@ public class CxfPayLoadSoapHeaderTest ex
}
})
- .to(serviceEndpointURI);
+ .to(getServiceEndpointURI());
// END SNIPPET: payload
}
};
}
-
- @Before
- public void setUp() throws Exception {
- applicationContext = createApplicationContext();
- super.setUp();
- assertNotNull("Should have created a valid spring context",
applicationContext);
- }
-
- @After
- public void tearDown() throws Exception {
- if (applicationContext != null) {
- applicationContext.destroy();
- }
- super.tearDown();
- }
+
@BeforeClass
public static void startService() {
@@ -133,15 +121,5 @@ public class CxfPayLoadSoapHeaderTest ex
return service.getPizzaPort();
}
- @Override
- protected CamelContext createCamelContext() throws Exception {
- return SpringCamelContext.springCamelContext(applicationContext);
- }
-
- protected ClassPathXmlApplicationContext createApplicationContext() {
- return new
ClassPathXmlApplicationContext("org/apache/camel/component/cxf/PizzaEndpoints.xml");
- }
-
-
}
Modified:
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerTest.java?rev=1055323&r1=1055322&r2=1055323&view=diff
==============================================================================
---
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerTest.java
(original)
+++
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerTest.java
Wed Jan 5 07:07:57 2011
@@ -27,7 +27,6 @@ import org.apache.camel.Processor;
import org.apache.camel.component.cxf.CxfConstants;
import org.apache.camel.component.cxf.jaxrs.testbean.Customer;
import org.apache.camel.test.junit4.CamelSpringTestSupport;
-import org.junit.Ignore;
import org.junit.Test;
import org.springframework.context.support.AbstractXmlApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -208,8 +207,7 @@ public class CxfRsProducerTest extends C
assertEquals("The response value is wrong", "q1=new&q2=world",
response);
}
- @Test
- @Ignore("TODO: Fixme")
+ @Test
public void testRestServerDirectlyGetCustomer() {
// we cannot convert directly to Customer as we need camel-jaxb
String response =
template.requestBodyAndHeader("cxfrs:http://localhost:9002/customerservice/customers/123",
Modified:
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/PizzaEndpoints.xml
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/PizzaEndpoints.xml?rev=1055323&r1=1055322&r2=1055323&view=diff
==============================================================================
---
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/PizzaEndpoints.xml
(original)
+++
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/PizzaEndpoints.xml
Wed Jan 5 07:07:57 2011
@@ -30,14 +30,10 @@
<!-- Added the import for testing the CAMEL-329 -->
<cxf:cxfEndpoint id="routerEndpoint"
address="http://localhost:9013/pizza_service/services/PizzaService"
- serviceClass="org.apache.camel.pizza.Pizza"/>
+ wsdlURL="pizza_service.wsdl"/>
<cxf:cxfEndpoint id="serviceEndpoint"
address="http://localhost:9023/new_pizza_service/services/PizzaService"
- wsdlURL="pizza_service.wsdl"
- serviceClass="org.apache.camel.pizza.Pizza"
- endpointName="s:PizzaPort"
- serviceName="s:PizzaService"
- xmlns:s="http://camel.apache.org/pizza" />
+ wsdlURL="pizza_service.wsdl"/>
</beans>
\ No newline at end of file