Camel CXF POJO mode using Java DSL

I have an existing β€œconnect” web service (SOAP) that I would call without using the Swing framework, if possible. I followed the first contact development creating my java files using the cxf / wsdl2java tool.

I want the username and password to be extracted from the java object and placed in a SOAP object, and then sent to my localhost web service.

When sending a Connect object as a body to "direct: start", I get an exception ...

Caused by: java.lang.IllegalArgumentException: Get the wrong parameter size to invoke the out service, Expect size 2, Parameter size 1. Please check if the message body matches the CXFEndpoint POJO Dataformat request. 

I checked the first argument - actually an instance of the Connect object that was passed.

Are additional annotations needed in one of the classes, is the validation method invalid or is there an alternative model that I should follow?

 public class TestConnectCXF extends CamelTestSupport { @Override protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { String cxfAddressLine = "cxf:http://localhost:8081/nuxeo/webservices/privateadservice?wsdlURL=wsdl/privateadservice.wsdl" // + "&dataFormat=POJO" // + "&serviceClass=com.sandbox.camelfeed.PrivateAdServiceInterface" // + "&serviceName={http://ws.sandboxtest.com/}PrivateAdService" // + "&synchronous=true" // + "&loggingFeatureEnabled=true" // + "&portName={http://ws.sandboxtest.com/}PrivateAdServiceInterfacePort"; @Override public void configure() throws Exception { from("direct:start").to(cxfAddressLine).to("mock:end"); } }; } @Test public void testConnectViaPojo() throws InterruptedException { Connect connectToServer = new Connect(); connectToServer.setUserName("FakeUser"); connectToServer.setPassword("scrubbed"); template.sendBody("direct:start", connectToServer); Thread.sleep(1000); } } 

I am new to camels and web services, so any helpful pointers would be greatly appreciated.

Additional Information

Using Camel 2.10, Java 1.6

Classes created from wsdl2java

 @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "connect", propOrder = { "userName", "password" }) public class Connect { protected String userName; protected String password; public String getUserName() { return userName; } public void setUserName(String value) { this.userName = value; } public String getPassword() { return password; } public void setPassword(String value) { this.password = value; } } @WebService(targetNamespace = "http://ws.sandboxtest.com/", name = "PrivateAdServiceInterface") @XmlSeeAlso({ObjectFactory.class}) public interface PrivateAdServiceInterface { // Omitted Code relating to other web calls @WebResult(name = "return", targetNamespace = "") @RequestWrapper(localName = "connect", targetNamespace = "http://ws.sandboxtest.com/", className = "com.sandbox.camelfeed.Connect") @WebMethod @ResponseWrapper(localName = "connectResponse", targetNamespace = "http://ws.sandboxtest.com/", className = "com.sandbox.camelfeed.ConnectResponse") public java.lang.String connect( @WebParam(name = "userName", targetNamespace = "") java.lang.String userName, @WebParam(name = "password", targetNamespace = "") java.lang.String password ) throws ClientException_Exception; } @XmlRegistry public class ObjectFactory { { // Omitted other web calls information private final static QName _Connect_QNAME = new QName("http://ws.sandboxtest.com/", "connect"); @XmlElementDecl(namespace = "http://ws.sandboxtest.com/", name = "connect") public JAXBElement<Connect> createConnect(Connect value) { return new JAXBElement<Connect>(_Connect_QNAME, Connect.class, null, value); } } 
+6
source share
2 answers

In my experience, there are some things in Camel, like calling a SOAP web service or calling REST, which are easier to do on a user processor than using a component like CXF, HTTP, or HTTP4.

I usually work with Spring, so for outgoing calls, I prefer to use the Spring REST template or JaxWsPortProxyFactoryBean (for Webservice calls).

Here is an example of using a JAX-WS call:

  public class WebServiceProcessorBean { @Autowired private JAXWSProxy theProxy; public void callWebservice(Exchange exchange) { Response response = theProxy.call(); //Do something with the response and Exchange. } } 

Definition in the context of a Spring application:

 <bean id="theProxyService" class="org.springframework.remoting.jaxws.JaxWsPortProxyFactoryBean"> <property name="serviceInterface" value="XXX"/> <property name="wsdlDocumentUrl" value="http://xxxxx.wsdl"/> <property name="namespaceUri" value="xxxx"/> <property name="serviceName" value="xxxx"/> <property name="portName" value="xxxxx"/> </bean> 

Use the WebServiceProcessorBean defined in the context of the Spring application using the DSL beanRef () method.

 .beanRef("theProxyService", "callWebservice") 
+3
source

I am also trying to dig up Apache Camel with CXF :).

I think the exception that throws is about the problem with the number of arguments. template.sendBody(what_is_called, input_parameter_s, output_parameter);

The output parameter is the most likely return value from the cxf web services call.

0
source

All Articles