Author: hadrian Date: Fri Jun 15 19:36:22 2012 New Revision: 1350748 URL: http://svn.apache.org/viewvc?rev=1350748&view=rev Log: CAMEL-5331. Thanks Gert for the patch
Added: camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfPayLoadBareSoapTest.java (with props) camel/branches/camel-2.8.x/components/camel-cxf/src/test/resources/bare.wsdl Modified: camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java Modified: camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java?rev=1350748&r1=1350747&r2=1350748&view=diff ============================================================================== --- camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java (original) +++ camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java Fri Jun 15 19:36:22 2012 @@ -809,8 +809,8 @@ public class CxfEndpoint extends Default } } - if (content.size() < elements.size()) { - LOG.warn("Cannot set right payload paremeters. Please check the BindingOperation and PayLoadMessage."); + if (elements != null && content.size() < elements.size()) { + LOG.warn("Cannot set right payload parameters. Please check the BindingOperation and PayLoadMessage."); throw new IllegalArgumentException( "The PayLoad elements cannot fit with the message parts of the BindingOperation. Please check the BindingOperation and PayLoadMessage."); } Added: camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfPayLoadBareSoapTest.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfPayLoadBareSoapTest.java?rev=1350748&view=auto ============================================================================== --- camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfPayLoadBareSoapTest.java (added) +++ camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfPayLoadBareSoapTest.java Fri Jun 15 19:36:22 2012 @@ -0,0 +1,94 @@ +/** + * 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 org.apache.camel.builder.RouteBuilder; +import org.apache.camel.test.AvailablePortFinder; +import org.apache.camel.test.junit4.CamelTestSupport; +import org.apache.cxf.frontend.ClientProxyFactoryBean; +import org.junit.BeforeClass; +import org.junit.Test; + +import javax.jws.WebService; +import javax.jws.soap.SOAPBinding; +import javax.xml.ws.Endpoint; +import java.util.concurrent.atomic.AtomicInteger; + +import static org.junit.Assert.assertEquals; + + +public class CxfPayLoadBareSoapTest extends CamelTestSupport { + + private static final int PORT = AvailablePortFinder.getNextAvailable(); + private static final String ORIGINAL_URL = + String.format("http://localhost:%s/original/Service", PORT); + private static final String PROXY_URL = + String.format("http://localhost:%s/proxy/Service", PORT); + private static final BareSoapServiceImpl IMPLEMENTATION = new BareSoapServiceImpl(); + + @BeforeClass + public static void startService() { + Endpoint.publish(ORIGINAL_URL, IMPLEMENTATION); + } + + protected String getRouterEndpointURI() { + return String.format("cxf:%s?dataFormat=PAYLOAD&wsdlURL=classpath:bare.wsdl", PROXY_URL); + } + + protected String getServiceEndpointURI() { + return String.format("cxf:%s?dataFormat=PAYLOAD&wsdlURL=classpath:bare.wsdl", ORIGINAL_URL); + } + + @Override + protected RouteBuilder createRouteBuilder() { + return new RouteBuilder() { + public void configure() { + from(getRouterEndpointURI()).to(getServiceEndpointURI()); + } + }; + } + + @Test + public void testInvokeProxyService() { + ClientProxyFactoryBean factory = new ClientProxyFactoryBean(); + factory.setServiceClass(BareSoapService.class); + factory.setAddress(PROXY_URL); + BareSoapService client = (BareSoapService) factory.create(); + + client.doSomething(); + + assertEquals("Proxied service should have been invoked once", 1, IMPLEMENTATION.invocations.get()); + } + + @WebService + @SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE) + public static interface BareSoapService { + + public void doSomething(); + + } + + public static class BareSoapServiceImpl implements BareSoapService { + + private AtomicInteger invocations = new AtomicInteger(0); + + public void doSomething() { + invocations.incrementAndGet(); + } + } + +} Propchange: camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfPayLoadBareSoapTest.java ------------------------------------------------------------------------------ svn:eol-style = native Added: camel/branches/camel-2.8.x/components/camel-cxf/src/test/resources/bare.wsdl URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-cxf/src/test/resources/bare.wsdl?rev=1350748&view=auto ============================================================================== --- camel/branches/camel-2.8.x/components/camel-cxf/src/test/resources/bare.wsdl (added) +++ camel/branches/camel-2.8.x/components/camel-cxf/src/test/resources/bare.wsdl Fri Jun 15 19:36:22 2012 @@ -0,0 +1,32 @@ +<?xml version='1.0' encoding='UTF-8'?> +<wsdl:definitions name="BareSoapServiceImplService" targetNamespace="http://cxf.component.camel.apache.org/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://cxf.component.camel.apache.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <wsdl:message name="doSomething"> + </wsdl:message> + <wsdl:message name="doSomethingResponse"> + </wsdl:message> + <wsdl:portType name="BareSoapService"> + <wsdl:operation name="doSomething"> + <wsdl:input message="tns:doSomething" name="doSomething"> + </wsdl:input> + <wsdl:output message="tns:doSomethingResponse" name="doSomethingResponse"> + </wsdl:output> + </wsdl:operation> + </wsdl:portType> + <wsdl:binding name="BareSoapServiceImplServiceSoapBinding" type="tns:BareSoapService"> + <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> + <wsdl:operation name="doSomething"> + <soap:operation soapAction="" style="document"/> + <wsdl:input name="doSomething"> + <soap:body use="literal"/> + </wsdl:input> + <wsdl:output name="doSomethingResponse"> + <soap:body use="literal"/> + </wsdl:output> + </wsdl:operation> + </wsdl:binding> + <wsdl:service name="BareSoapServiceImplService"> + <wsdl:port binding="tns:BareSoapServiceImplServiceSoapBinding" name="BareSoapServiceImplPort"> + <!-- <soap:address location="http://localhost:10000/original/Service"/> --> + </wsdl:port> + </wsdl:service> +</wsdl:definitions> \ No newline at end of file