Dear William,

Actually Web method contains single argument, so I have passed
"Hello"(*exchange.getIn().setBody("Hello"); *). Can u tell me what is the
problem of bellow code.

*Web Service Method:*
         public String getApplication(String data) { 
                System.out.println("getApplication"); 
                return "GetApplication Method Call :"; 
         } 

*Calling Code.*
static CamelContext context; 

        public static void main(String args[]) throws Exception { 
                CamelContext context = new DefaultCamelContext(); 
                ProducerTemplate template =
context.createProducerTemplate(0); 
                context.start(); 
                String url =
"cxf://http://localhost:8081/buzzor-service/services/ApplicationService?"; 
                                +
"wsdlURL=http://localhost:8081/buzzor-service/services/ApplicationService?wsdl&";
 
                                +
"serviceName={http://service.application.buzzor.atpl.com}ApplicationService&"; 
                                +
"portName={http://service.application.buzzor.atpl.com}ApplicationServiceHttpPort&";
 
                                + "dataFormat=MESSAGE"; 
                Exchange reply = sendSimpleMessage(template, url); 
                org.apache.camel.Message out = reply.getOut(); 
                String result = out.getBody(String.class); 

                System.out.println(reply); 
                Thread.sleep(10000); 
                context.stop(); 
        } 

private static Exchange sendSimpleMessage(ProducerTemplate template, 
                        String endpointUri) { 

                Exchange exchange = template.request(endpointUri, new
Processor() { 
                        public void process(final Exchange exchange) { 
                                exchange.getIn().setBody("Hello"); 
                               
exchange.getIn().setHeader(CxfConstants.OPERATION_NAME, 
                                                "getApplication"); 
                               
exchange.getIn().setHeader(CxfConstants.OPERATION_NAMESPACE, 
                                               
"http://service.application.buzzor.atpl.com";); 
                               
exchange.getIn().setHeader(Exchange.FILE_NAME, "testFile"); 
                                exchange.getIn().setHeader("requestObject", 
                                                new DefaultCxfBinding()); 
                         } 
                }); 
                return exchange; 

        } 

*After Executing this code. no error thrown by this code but web service
also not called. 

in result variable Bellow Message has been received 

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";
xmlns:xsd="http://www.w3.org/2001/XMLSchema";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>ParseError
at [row,col]:[1,1] 
Message: Content is not allowed in
prolog.</faultstring></soap:Fault></soap:Body></soap:Envelope>*



--
View this message in context: 
http://camel.465427.n5.nabble.com/How-can-I-call-a-web-service-with-no-parameters-via-a-producerTemplate-tp4806257p5745433.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to