I am trying to consume a public service using Mule + apache cxf. The service is available at http://www.html2xml.nl/Services/Calculator/Version1/Calculator.asmx?WSDL
This is a very simple service which does basic arithmetic operations. I am trying to call the operation "Add" here. My mule configuration is as below
<flow name="calculator" doc:name="calculator">
<stdio:inbound-endpoint system="IN" doc:name="STDIO"/>
<custom-transformer class="com.calculator.transformer.CalculatorClient" doc:name="Java"/>
<outbound-endpoint address="http://localhost:28081/service/Calculator?WSDL" exchange-pattern="request-response" doc:name="HTTP">
<cxf:jaxws-client clientClass="com.calculator.wsdl.Calculator" enableMuleSoapHeaders="true" port="CalculatorHttpPost" wsdlLocation="classpath:/wsdl/Calculator.wsdl" operation="Add">
<cxf:inInterceptors>
<spring:bean class="org.apache.cxf.interceptor.LoggingInInterceptor" />
</cxf:inInterceptors>
<cxf:outInterceptors>
<spring:bean class="org.apache.cxf.interceptor.LoggingOutInterceptor" />
</cxf:outInterceptors>
</cxf:jaxws-client>
</outbound-endpoint>
<transformer ref="CalculatorResponse" doc:name="Transformer Reference"/>
<mulexml:jaxb-object-to-xml-transformer name="CalculatortoXML" jaxbContext-ref="myJaxbCal" />
<stdio:outbound-endpoint system="OUT" doc:name="STDIO"/>
</flow>
Before calling the client class i added a transformer as below. This just sets the 2 numbers to add.
Code
package com.calculator.transformer;
import org.mule.api.MuleMessage;
import org.mule.api.transformer.TransformerException;
import org.mule.transformer.AbstractMessageTransformer;
import com.calculator.wsdl.Add;
public class CalculatorClient extends AbstractMessageTransformer {
@Override
public Object transformMessage(MuleMessage message, String outputEncoding)
throws TransformerException {
Add add= new Add();
add.setA(3);
add.setB(3);
return add;
}
}
Once i start mule i receive the error.Not sure what i am doing wrong.
ERROR 2014-01-16 01:09:46,237 [[weatherproject].calculator.stage1.02] org.mule.exception.DefaultMessagingExceptionStrategy:
Message : wrong number of arguments. Failed to route event via endpoint: org.mule.module.cxf.CxfOutboundMessageProcessor. Message payload is of type: Add
Code : MULE_ERROR--2
Exception stack is:
1. wrong number of arguments (java.lang.IllegalArgumentException)
sun.reflect.NativeMethodAccessorImpl:-2 (null)
2. wrong number of arguments. Failed to route event via endpoint: org.mule.module.cxf.CxfOutboundMessageProcessor. Message payload is of type: Add (org.mule.api.transport.DispatchException)
org.mule.module.cxf.CxfOutboundMessageProcessor:148 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transport/DispatchException.html)
Root Exception stack trace:
java.lang.IllegalArgumentException: wrong number of arguments
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)