You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Raju Mandala <ir...@gmail.com> on 2014/07/18 10:51:26 UTC

Passing SOAP XML to the CXF endpoint

Hi,
I have a requirement "While routing in camel, i have to call a web
service". But i am struck with setting SOAP xml to the exchange. Can some
one help me with this. Please have a look at my code

public static void main(String[] args) throws Exception {
        CamelContext context = new DefaultCamelContext();
        context.addRoutes(new RouteBuilder() {

            @Override
            public void configure() throws Exception {
                from("file:input?noop=true")
                        .process(new Processor() {
                            @Override
                            public void process(Exchange exchange)
throws Exception {
                                //Setting a String to the exchange body
                                exchange.getIn().setBody("Just a String");
                                //Now i want to set a SOAP xml to the
exchange body
                                //exchange.getIn().setBody();
                                System.out.println("Ravi "+
exchange.getIn().getBody(String.class));
                            }
                        })

.to("cxf://http://www.webservicex.net/stockquote.asmx?wsdlURL=src/main/resources/META-INF/stockquote.wsdl&serviceName={http://www.webserviceX.NET/}StockQuote&portName={http://www.webserviceX.NET/}StockQuoteSoap&dataFormat=MESSAGE")
                        .process(new Processor() {
                            @Override
                            public void process(Exchange exchange)
throws Exception {
                                System.out.println("Raju" + exchange);
                            }
                        }).to("file:data/destination?fileName=test2.xml");
            }
        });
        context.start();
        Thread.sleep(20000);
        context.stop();
    }



~Raju

Re: Passing SOAP XML to the CXF endpoint

Posted by Aki Yoshida <el...@gmail.com>.
what's the error?
the service returning a soap faull complaing the missign soapaction header?

in that case, you need to set the soapaction header (i.e.,
.setHeader("soapaction", ...) explicitly or set the operation name
header (i.e., .setHeader("operationName", ...) so that the correct
soapaction is generated.

regards, aki

2014-07-18 10:51 GMT+02:00 Raju Mandala <ir...@gmail.com>:
> Hi,
> I have a requirement "While routing in camel, i have to call a web
> service". But i am struck with setting SOAP xml to the exchange. Can some
> one help me with this. Please have a look at my code
>
> public static void main(String[] args) throws Exception {
>         CamelContext context = new DefaultCamelContext();
>         context.addRoutes(new RouteBuilder() {
>
>             @Override
>             public void configure() throws Exception {
>                 from("file:input?noop=true")
>                         .process(new Processor() {
>                             @Override
>                             public void process(Exchange exchange)
> throws Exception {
>                                 //Setting a String to the exchange body
>                                 exchange.getIn().setBody("Just a String");
>                                 //Now i want to set a SOAP xml to the
> exchange body
>                                 //exchange.getIn().setBody();
>                                 System.out.println("Ravi "+
> exchange.getIn().getBody(String.class));
>                             }
>                         })
>
> .to("cxf://http://www.webservicex.net/stockquote.asmx?wsdlURL=src/main/resources/META-INF/stockquote.wsdl&serviceName={http://www.webserviceX.NET/}StockQuote&portName={http://www.webserviceX.NET/}StockQuoteSoap&dataFormat=MESSAGE")
>                         .process(new Processor() {
>                             @Override
>                             public void process(Exchange exchange)
> throws Exception {
>                                 System.out.println("Raju" + exchange);
>                             }
>                         }).to("file:data/destination?fileName=test2.xml");
>             }
>         });
>         context.start();
>         Thread.sleep(20000);
>         context.stop();
>     }
>
>
>
> ~Raju