Hi,

I'm new to Camel and currently trying to setup a soap call to a web service
as part of my learning process.

*Environment:* JDK 1.6, Camel 2.11.0

*Web service:* http://www.webservicex.net/stockquote.asmx
*WSDL:* http://www.webservicex.net/stockquote.asmx?WSDL

*Client stub classes* generated based on WSDL with wsdl2java:

- GetQuote.java
- GetQuoteResponse.java
- ObjectFactory.java
- package-info.java
- StockQuote.java
- StockQuoteSoap.java

*In spring-camel.xml* I have:

    <cxf:cxfEndpoint id="serviceEndpoint" 
                address="http://www.webservicex.net/stockquote.asmx";
            wsdlURL="http://www.webservicex.net/stockquote.asmx?WSDL";
            serviceClass="net.webservicex.StockQuoteSoap">
            <cxf:properties>
                <entry key="dataFormat" value="POJO"/> 
            </cxf:properties>            
    </cxf:cxfEndpoint>

*The route* is simple:

        
from("jms:queue:SoapRequestQueue?jmsMessageType=Text&concurrentConsumers=5")
                .process(new QueueProcessor())
                .to("cxf:bean:serviceEndpoint?dataFormat=POJO")
                .process(new WsProcessor())
                .to("mock:end");

    * Input is through an ActiveMQ queue.

*QueueProcessor* class takes the ActiveMQ input and wraps it into GetQuote
object:

public class QueueProcessor implements Processor {

        public void process(Exchange exchange) throws Exception {
                String symbol = exchange.getIn().getBody(String.class);
        GetQuote req = new GetQuote();
        req.setSymbol(symbol);
        exchange.getOut().setBody(req, GetQuote.class);
    }
}  

*WsProcessor* is supposed to retrieve the response:

public class WsProcessor implements Processor {
        public void process(Exchange exchange) throws Exception {
                MessageContentsList msgList = (MessageContentsList)
exchange.getIn().getBody();
                GetQuoteResponse resp = (GetQuoteResponse) msgList.get(0);
                String result = resp.getGetQuoteResult();
                exchange.getIn().setBody(result, String.class);
    }
}

When I run it, I got the following *exception*:

(camelContext) thread #34 - JmsConsumer[SoapRequestQueue]] WARN 
o.a.cxf.phase.PhaseInterceptorChain - Interceptor for
{http://www.webserviceX.NET/}StockQuoteSoapService#{http://www.webserviceX.NET/}GetQuote
has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: net.webservicex.GetQuote cannot be cast to
java.lang.String
        at
org.apache.cxf.jaxws.interceptors.WrapperClassOutInterceptor.handleMessage(WrapperClassOutInterceptor.java:117)
~[cxf-rt-frontend-jaxws-2.7.6.jar:2.7.6]
        at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271)
~[cxf-api-2.7.6.jar:2.7.6]
        at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:541)
[cxf-api-2.7.6.jar:2.7.6]
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:467)
[cxf-api-2.7.6.jar:2.7.6]
        at 
org.apache.camel.component.cxf.CxfProducer.process(CxfProducer.java:112)
[camel-cxf-2.11.0.jar:2.11.0]

I'm stuck here, can someone help me with this?

Thanks!



--
View this message in context: 
http://camel.465427.n5.nabble.com/cxf-soap-call-exception-when-using-dataFormat-POJO-tp5736712.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to