You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by Ritwick <ri...@gmail.com> on 2014/06/30 23:11:43 UTC

Camel Routes

Hi,
I am not sure if this is the correct Camel forum for this issue I am having.
However, I am unable to find an appropriate forum - so I am posting my
question here. It will be great if someone can either guide me to the
correct forum or better still rectify the issue I am facing.
Here is what I need to do - expose a restlet endpoint to accept data; use
this data as input to an external SOAP web service and send back the
response in JSON format back to the caller...
Here is what I have done...however, I am getting the following error while
Camel tries to call the Web Service...can anyone guide me here? Thanks.

2014-06-30 14:09:24,987 [tlet-1846031557] WARN  PhaseInterceptorChain         
- Interceptor for
{http://www.webserviceX.NET/}CurrencyConvertor#{http://www.webserviceX.NET/}ConversionRate
has thrown exception, unwinding now
java.lang.ClassCastException: ClassCastException invoking
http://www.webservicex.net/CurrencyConvertor.asmx:
org.restlet.data.Parameter cannot be cast to java.lang.String


public class IntegrationTest extends CamelTestSupport {

    @org.junit.Test
    public void integTest() throws Exception {
    	//trying to simulate the rest service call...
  
template.sendBodyAndHeader("restlet:http://localhost:8080/convert/{data}?restletMethods=get",
"Body does not matter here", "data",
"{\"FromCurrency\":\"AUD\",\"ToCurrency\":\"USD\"}");
        
    }


    @Override
    protected RouteBuilder createRouteBuilder() throws Exception {
        return new RouteBuilder() {
            @Override
            public void configure() throws Exception {
            	System.out.println("In Counfigure");

        		String cxfEndpoint =
"cxf://http://www.webservicex.net/CurrencyConvertor.asmx?"
        				+
"wsdlURL=http://www.webservicex.net/CurrencyConvertor.asmx?wsdl&"
        				+ "serviceName={http://www.webserviceX.NET/}CurrencyConvertor&"
        				+ "portName={http://www.webserviceX.NET/}CurrencyConvertorSoap&"
        				+ "dataFormat=MESSAGE";
        				
        		XmlJsonDataFormat xmlJsonFormat = new XmlJsonDataFormat();
        		SoapJaxbDataFormat soap = new
SoapJaxbDataFormat("net.webservicex", new
ServiceInterfaceStrategy(CurrencyConvertorSoap.class, true));

				GsonDataFormat gson = new GsonDataFormat(ConversionRate.class);
				gson.setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE);
				
from("restlet:http://localhost:8080/convert/{data}?restletMethods=get").routeId("Restlet")
				.process(new Processor() {
					@Override
					public void process(Exchange exchange) throws Exception {
						String data = (String) URLDecoder.decode((String)
exchange.getIn().getHeader("data"), "UTF-8");
						System.out.println(data);
						// get the mail body as a String
						exchange.getIn().setBody(data);
						Response.getCurrent().setStatus(Status.SUCCESS_OK);
			        }
					
				})
		.unmarshal(gson)
                .marshal(soap)
                .log("${body}")
                .to(cxfEndpoint)
                .unmarshal(soap)
                .marshal(xmlJsonFormat);
                .log("${body}");
            }
        };
    }
}




--
View this message in context: http://activemq.2283324.n4.nabble.com/Camel-Routes-tp4682675.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.

Re: Camel Routes

Posted by Ritwick <ri...@gmail.com>.
Thanks for your response Claus - yes, I have already added the query in the
Camel discussion forum at
http://camel.465427.n5.nabble.com/Issue-with-Camel-td5753081.html.
If you could take a look at it and respond, that will be great.

Thanks,
Ritwick.


On Tue, Jul 1, 2014 at 6:22 AM, Claus Ibsen [via ActiveMQ] <
ml-node+s2283324n4682696h32@n4.nabble.com> wrote:

> Hi
>
> Yeah this is ActiveMQ forum so better ask at Camel forum / user mailing
> list
> http://camel.apache.org/discussion-forums.html
> http://camel.apache.org/mailing-lists.html
>
>
> On Mon, Jun 30, 2014 at 11:11 PM, Ritwick <[hidden email]
> <http://user/SendEmail.jtp?type=node&node=4682696&i=0>> wrote:
>
> > Hi,
> > I am not sure if this is the correct Camel forum for this issue I am
> having.
> > However, I am unable to find an appropriate forum - so I am posting my
> > question here. It will be great if someone can either guide me to the
> > correct forum or better still rectify the issue I am facing.
> > Here is what I need to do - expose a restlet endpoint to accept data;
> use
> > this data as input to an external SOAP web service and send back the
> > response in JSON format back to the caller...
> > Here is what I have done...however, I am getting the following error
> while
> > Camel tries to call the Web Service...can anyone guide me here? Thanks.
> >
> > 2014-06-30 14:09:24,987 [tlet-1846031557] WARN  PhaseInterceptorChain
> > - Interceptor for
> > {http://www.webserviceX.NET/}CurrencyConvertor#{
> http://www.webserviceX.NET/}ConversionRate
> > has thrown exception, unwinding now
> > java.lang.ClassCastException: ClassCastException invoking
> > http://www.webservicex.net/CurrencyConvertor.asmx:
> > org.restlet.data.Parameter cannot be cast to java.lang.String
> >
> >
> > public class IntegrationTest extends CamelTestSupport {
> >
> >     @org.junit.Test
> >     public void integTest() throws Exception {
> >         //trying to simulate the rest service call...
> >
> > template.sendBodyAndHeader("restlet:http://localhost:8080/convert/{data}?restletMethods=get",
>
> > "Body does not matter here", "data",
> > "{\"FromCurrency\":\"AUD\",\"ToCurrency\":\"USD\"}");
> >
> >     }
> >
> >
> >     @Override
> >     protected RouteBuilder createRouteBuilder() throws Exception {
> >         return new RouteBuilder() {
> >             @Override
> >             public void configure() throws Exception {
> >                 System.out.println("In Counfigure");
> >
> >                         String cxfEndpoint =
> > "cxf://http://www.webservicex.net/CurrencyConvertor.asmx?"
> >                                         +
> > "wsdlURL=http://www.webservicex.net/CurrencyConvertor.asmx?wsdl&"
> >                                         + "serviceName={
> http://www.webserviceX.NET/}CurrencyConvertor&"
> >                                         + "portName={
> http://www.webserviceX.NET/}CurrencyConvertorSoap&"
> >                                         + "dataFormat=MESSAGE";
> >
> >                         XmlJsonDataFormat xmlJsonFormat = new
> XmlJsonDataFormat();
> >                         SoapJaxbDataFormat soap = new
> > SoapJaxbDataFormat("net.webservicex", new
> > ServiceInterfaceStrategy(CurrencyConvertorSoap.class, true));
> >
> >                                 GsonDataFormat gson = new
> GsonDataFormat(ConversionRate.class);
> >
> gson.setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE);
> >
> > from("restlet:http://localhost:8080/convert/{data}?restletMethods=get").routeId("Restlet")
>
> >                                 .process(new Processor() {
> >                                         @Override
> >                                         public void process(Exchange
> exchange) throws Exception {
> >                                                 String data = (String)
> URLDecoder.decode((String)
> > exchange.getIn().getHeader("data"), "UTF-8");
> >
> System.out.println(data);
> >                                                 // get the mail body as
> a String
> >
> exchange.getIn().setBody(data);
> >
> Response.getCurrent().setStatus(Status.SUCCESS_OK);
> >                                 }
> >
> >                                 })
> >                 .unmarshal(gson)
> >                 .marshal(soap)
> >                 .log("${body}")
> >                 .to(cxfEndpoint)
> >                 .unmarshal(soap)
> >                 .marshal(xmlJsonFormat);
> >                 .log("${body}");
> >             }
> >         };
> >     }
> > }
> >
> >
> >
> >
> > --
> > View this message in context:
> http://activemq.2283324.n4.nabble.com/Camel-Routes-tp4682675.html
> > Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
>
>
>
> --
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> Email: [hidden email]
> <http://user/SendEmail.jtp?type=node&node=4682696&i=1>
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
> hawtio: http://hawt.io/
> fabric8: http://fabric8.io/
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
> http://activemq.2283324.n4.nabble.com/Camel-Routes-tp4682675p4682696.html
>  To unsubscribe from Camel Routes, click here
> <http://activemq.2283324.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4682675&code=cml0d2ljazVnaG9zaEBnbWFpbC5jb218NDY4MjY3NXw5MTk2MTM2Mzg=>
> .
> NAML
> <http://activemq.2283324.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>



-- 
Thanks and Regards,
Ritwick.




--
View this message in context: http://activemq.2283324.n4.nabble.com/Camel-Routes-tp4682675p4682710.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.

Re: Camel Routes

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Yeah this is ActiveMQ forum so better ask at Camel forum / user mailing list
http://camel.apache.org/discussion-forums.html
http://camel.apache.org/mailing-lists.html

On Mon, Jun 30, 2014 at 11:11 PM, Ritwick <ri...@gmail.com> wrote:
> Hi,
> I am not sure if this is the correct Camel forum for this issue I am having.
> However, I am unable to find an appropriate forum - so I am posting my
> question here. It will be great if someone can either guide me to the
> correct forum or better still rectify the issue I am facing.
> Here is what I need to do - expose a restlet endpoint to accept data; use
> this data as input to an external SOAP web service and send back the
> response in JSON format back to the caller...
> Here is what I have done...however, I am getting the following error while
> Camel tries to call the Web Service...can anyone guide me here? Thanks.
>
> 2014-06-30 14:09:24,987 [tlet-1846031557] WARN  PhaseInterceptorChain
> - Interceptor for
> {http://www.webserviceX.NET/}CurrencyConvertor#{http://www.webserviceX.NET/}ConversionRate
> has thrown exception, unwinding now
> java.lang.ClassCastException: ClassCastException invoking
> http://www.webservicex.net/CurrencyConvertor.asmx:
> org.restlet.data.Parameter cannot be cast to java.lang.String
>
>
> public class IntegrationTest extends CamelTestSupport {
>
>     @org.junit.Test
>     public void integTest() throws Exception {
>         //trying to simulate the rest service call...
>
> template.sendBodyAndHeader("restlet:http://localhost:8080/convert/{data}?restletMethods=get",
> "Body does not matter here", "data",
> "{\"FromCurrency\":\"AUD\",\"ToCurrency\":\"USD\"}");
>
>     }
>
>
>     @Override
>     protected RouteBuilder createRouteBuilder() throws Exception {
>         return new RouteBuilder() {
>             @Override
>             public void configure() throws Exception {
>                 System.out.println("In Counfigure");
>
>                         String cxfEndpoint =
> "cxf://http://www.webservicex.net/CurrencyConvertor.asmx?"
>                                         +
> "wsdlURL=http://www.webservicex.net/CurrencyConvertor.asmx?wsdl&"
>                                         + "serviceName={http://www.webserviceX.NET/}CurrencyConvertor&"
>                                         + "portName={http://www.webserviceX.NET/}CurrencyConvertorSoap&"
>                                         + "dataFormat=MESSAGE";
>
>                         XmlJsonDataFormat xmlJsonFormat = new XmlJsonDataFormat();
>                         SoapJaxbDataFormat soap = new
> SoapJaxbDataFormat("net.webservicex", new
> ServiceInterfaceStrategy(CurrencyConvertorSoap.class, true));
>
>                                 GsonDataFormat gson = new GsonDataFormat(ConversionRate.class);
>                                 gson.setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE);
>
> from("restlet:http://localhost:8080/convert/{data}?restletMethods=get").routeId("Restlet")
>                                 .process(new Processor() {
>                                         @Override
>                                         public void process(Exchange exchange) throws Exception {
>                                                 String data = (String) URLDecoder.decode((String)
> exchange.getIn().getHeader("data"), "UTF-8");
>                                                 System.out.println(data);
>                                                 // get the mail body as a String
>                                                 exchange.getIn().setBody(data);
>                                                 Response.getCurrent().setStatus(Status.SUCCESS_OK);
>                                 }
>
>                                 })
>                 .unmarshal(gson)
>                 .marshal(soap)
>                 .log("${body}")
>                 .to(cxfEndpoint)
>                 .unmarshal(soap)
>                 .marshal(xmlJsonFormat);
>                 .log("${body}");
>             }
>         };
>     }
> }
>
>
>
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/Camel-Routes-tp4682675.html
> Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/