Author: janstey Date: Thu May 6 13:44:48 2010 New Revision: 941723 URL: http://svn.apache.org/viewvc?rev=941723&view=rev Log: CAMEL-2700 - cxfbean component should ignore the wsdlLocation in the POJO
Added: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/cxfbean/CxfBeanWithWsdlLocationInBeanTest.java (with props) camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/wsdl_first/PersonImplWithWsdl.java (with props) camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/cxfbean/CxfBeanWithWsdlLocationInBeanTest-context.xml (with props) Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/cxfbean/CxfBeanEndpoint.java Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/cxfbean/CxfBeanEndpoint.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/cxfbean/CxfBeanEndpoint.java?rev=941723&r1=941722&r2=941723&view=diff ============================================================================== --- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/cxfbean/CxfBeanEndpoint.java (original) +++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/cxfbean/CxfBeanEndpoint.java Thu May 6 13:44:48 2010 @@ -50,6 +50,7 @@ public class CxfBeanEndpoint extends Pro private CxfBeanBinding cxfBeanBinding = new DefaultCxfBeanBinding(); private HeaderFilterStrategy headerFilterStrategy = new CxfHeaderFilterStrategy(); private boolean loggingFeatureEnabled; + private boolean populateFromClass = true; public CxfBeanEndpoint(String remaining, CxfBeanComponent component) { super(remaining, component); @@ -100,6 +101,9 @@ public class CxfBeanEndpoint extends Pro JaxWsServerFactoryBean bean = new JaxWsServerFactoryBean(); bean.setTransportId(CxfBeanTransportFactory.TRANSPORT_ID); bean.setServiceClass(serviceBeans.get(0).getClass()); + if (bean.getServiceFactory() != null) { + bean.getServiceFactory().setPopulateFromClass(isPopulateFromClass()); + } bean.setBus(bus); bean.setStart(true); bean.setAddress("camel://" + createEndpointUri()); @@ -184,4 +188,11 @@ public class CxfBeanEndpoint extends Pro return loggingFeatureEnabled; } + public void setPopulateFromClass(boolean populateFromClass) { + this.populateFromClass = populateFromClass; + } + + public boolean isPopulateFromClass() { + return populateFromClass; + } } Added: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/cxfbean/CxfBeanWithWsdlLocationInBeanTest.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/cxfbean/CxfBeanWithWsdlLocationInBeanTest.java?rev=941723&view=auto ============================================================================== --- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/cxfbean/CxfBeanWithWsdlLocationInBeanTest.java (added) +++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/cxfbean/CxfBeanWithWsdlLocationInBeanTest.java Thu May 6 13:44:48 2010 @@ -0,0 +1,61 @@ +/** + * 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.cxfbean; + +import org.apache.commons.httpclient.HttpClient; +import org.apache.commons.httpclient.methods.PostMethod; +import org.apache.commons.httpclient.methods.RequestEntity; +import org.apache.commons.httpclient.methods.StringRequestEntity; +import org.junit.Test; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests; + +import static org.junit.Assert.assertEquals; + +/** + * + * @version $Revision: 835174 $ + */ +...@contextconfiguration +public class CxfBeanWithWsdlLocationInBeanTest extends AbstractJUnit4SpringContextTests { + + @Test + public void testDoNotUseWsdlDefinedInJaxWsBeanByDefault() throws Exception { + PostMethod post = new PostMethod("http://localhost:9090/customerservice/customers"); + post.addRequestHeader("Accept" , "text/xml"); + String body = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" + + "<soap:Body><GetPerson xmlns=\"http://camel.apache.org/wsdl-first/types\">" + + "<personId>hello</personId></GetPerson></soap:Body></soap:Envelope>"; + + RequestEntity entity = new StringRequestEntity(body, "text/xml", "ISO-8859-1"); + post.setRequestEntity(entity); + HttpClient httpclient = new HttpClient(); + + try { + assertEquals(200, httpclient.executeMethod(post)); + String response = post.getResponseBodyAsString(); + String correct = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><soap:Body>" + + "<GetPersonResponse xmlns=\"http://camel.apache.org/wsdl-first/types\">" + + "<personId>hello</personId><ssn>000-000-0000</ssn><name>Bonjour</name></GetPersonResponse></soap:Body></soap:Envelope>"; + + assertEquals("Get a wrong response", correct, response); + } finally { + post.releaseConnection(); + } + } + +} Propchange: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/cxfbean/CxfBeanWithWsdlLocationInBeanTest.java ------------------------------------------------------------------------------ svn:eol-style = native Added: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/wsdl_first/PersonImplWithWsdl.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/wsdl_first/PersonImplWithWsdl.java?rev=941723&view=auto ============================================================================== --- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/wsdl_first/PersonImplWithWsdl.java (added) +++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/wsdl_first/PersonImplWithWsdl.java Thu May 6 13:44:48 2010 @@ -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; + +...@webservice(serviceName = "PersonService", + targetNamespace = "http://camel.apache.org/wsdl-first", + wsdlLocation = "http://localhost:9090/customerservice/customers?wsdl", + endpointInterface = "org.apache.camel.wsdl_first.Person") +public class PersonImplWithWsdl implements Person { + + public void getPerson(Holder<String> personId, Holder<String> ssn, + Holder<String> name) throws UnknownPersonFault { + 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("Get the null value of person name", fault); + } + name.value = "Bonjour"; + ssn.value = "000-000-0000"; + } + +} Propchange: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/wsdl_first/PersonImplWithWsdl.java ------------------------------------------------------------------------------ svn:eol-style = native Added: camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/cxfbean/CxfBeanWithWsdlLocationInBeanTest-context.xml URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/cxfbean/CxfBeanWithWsdlLocationInBeanTest-context.xml?rev=941723&view=auto ============================================================================== --- camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/cxfbean/CxfBeanWithWsdlLocationInBeanTest-context.xml (added) +++ camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/cxfbean/CxfBeanWithWsdlLocationInBeanTest-context.xml Thu May 6 13:44:48 2010 @@ -0,0 +1,33 @@ +<?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" + xsi:schemaLocation=" + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd + http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd + http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd + "> + + <bean class="org.apache.camel.wsdl_first.PersonImplWithWsdl" id="jaxwsBean" /> + + <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"> + <route> + <from uri="jetty:http://localhost:9090?matchOnUriPrefix=true" /> + <to uri="cxfbean:jaxwsBean" /> + </route> + </camelContext> + +</beans> \ No newline at end of file Propchange: camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/cxfbean/CxfBeanWithWsdlLocationInBeanTest-context.xml ------------------------------------------------------------------------------ svn:eol-style = native