Hi Charles, It is not related the SOAP Action. From the stack trace I can tell you may not pass a right OperationName header. BTW, you can set the defaultOperationName on the CXFEndpointBean or CXFEndpoint URI.
-- Willem Jiang Red Hat, Inc. FuseSource is now part of Red Hat Web: http://www.fusesource.com | http://www.redhat.com Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English) http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese) Twitter: willemjiang Weibo: 姜宁willem On Tuesday, March 26, 2013 at 5:25 PM, Charles Moulliard wrote: > Hi, > > When in a Unit Test I use template.requestBody() with a WebService (which > is working perfectly using by example SOAP UI), I get the following error : > > - Is it because the SOAP Acton is not defined ? > - As my code is similar to this one ( > https://code.google.com/p/camelinaction/source/browse/trunk/chapter6/dataset/src/test/java/camelinaction/AcmeDataSetTest.java?r=47) > what could be the problem ? > > > org.apache.camel.CamelExecutionException: Exception occurred during > execution on the exchange: Exchange[Message: > org.fusesource.example.GetCustomerByName@4da3dc1d] > at > org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1335) > at > org.apache.camel.util.ExchangeHelper.extractResultBody(ExchangeHelper.java:618) > at > org.apache.camel.impl.DefaultProducerTemplate.extractResultBody(DefaultProducerTemplate.java:454) > at > org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:120) > at > org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:136) > at > org.apache.camel.impl.DefaultProducerTemplate.requestBody(DefaultProducerTemplate.java:284) > at > org.apache.camel.impl.DefaultProducerTemplate.requestBody(DefaultProducerTemplate.java:314) > at > org.fusesource.example.camel.webservice.CustomerWebServiceTest.testCustomerFuse(CustomerWebServiceTest.java:65) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at > org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) > at > org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) > at > org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) > at > org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) > at > org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) > at > org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30) > at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:47) > at org.junit.rules.RunRules.evaluate(RunRules.java:18) > at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) > at > org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) > at > org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) > at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) > at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) > at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) > at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) > at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) > at > org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30) > at org.junit.runners.ParentRunner.run(ParentRunner.java:300) > at org.junit.runner.JUnitCore.run(JUnitCore.java:157) > at > com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:76) > at > com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:195) > at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) > at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) > Caused by: java.lang.IllegalArgumentException: Get the wrong parameter size > to invoke the out service, Expect size 0, Parameter size 1. Please check if > the message body matches the CXFEndpoint POJO Dataformat request. > at > org.apache.camel.component.cxf.CxfProducer.checkParameterSize(CxfProducer.java:262) > at > org.apache.camel.component.cxf.CxfProducer.getParams(CxfProducer.java:301) > at org.apache.camel.component.cxf.CxfProducer.process(CxfProducer.java:112) > at > org.apache.camel.processor.UnitOfWorkProcessor.processAsync(UnitOfWorkProcessor.java:150) > at > org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:117) > at > org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:99) > at > org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:86) > at > org.apache.camel.processor.UnitOfWorkProducer.process(UnitOfWorkProducer.java:63) > at > org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:366) > at > org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:337) > at org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:233) > at org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:337) > at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:192) > at > org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:115) > at > org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:119) > ... 35 more > > Code > > public class CustomerWebServiceTest extends CamelSpringTestSupport { > > .... > > @Override > protected AbstractXmlApplicationContext createApplicationContext() { > return new > ClassPathXmlApplicationContext("META-INF/spring/camelContext.xml"); > } > > @Test > public void testCustomerFuse() throws Exception { > > GetCustomerByName searchCustomer = new GetCustomerByName(); > searchCustomer.setName("Fuse"); > > GetCustomerByNameResponse reply = > template.requestBody("cxf:bean:WS", searchCustomer, > GetCustomerByNameResponse.class); > assertEquals(searchCustomer.getName(),"Fuse"); > > } > } > > <route id="customers-webservice"> > <from uri="cxf:bean:WS"/> > <choice> > <when> > <simple>${in.header.SOAPAction} contains > 'getCustomerByName'</simple> > <log message=">>> We will search a Customer"/> > <bean method="getCustomerByName" ref="customerServiceBean"/> > </when> > <when> > <simple>${in.header.SOAPAction} contains 'saveCustomer'</simple> > <log message=">>> We will save a Customer"/> > <bean method="saveCustomer" ref="customerServiceBean"/> > </when> > <when> > <simple>${in.header.SOAPAction} contains > 'getAllCustomers'</simple> > <log message=">>> We will get all Customers"/> > <bean method="getCustomers" ref="customerServiceBean"/> > </when> > </choice> > </route> > > > Regards, > > -- > Charles Moulliard > Apache Committer / Sr. Enterprise Architect (RedHat) > Twitter : @cmoulliard | Blog : http://cmoulliard.blogspot.com
