You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "anish.somadevan" <ne...@gmail.com> on 2015/08/02 09:09:33 UTC

Re: Camel Restlet

Am having a similar kind of issue where am not able to send custom headers to
a REST URL using camel restlet. This is my route,

<route id="callRESTAPI">
        <from uri="Myapplication" />
		<from uri="direct:start"/>
           <setHeader headerName="Authorization">
           <simple>token</simple>
           </setHeader>
		<to uri="restlet:http://MyRESTAPI/messages"/>
	</route>

But i get a error message from the API mentioning that the header is
missing. Is there a way to set Custom headers in camel restlet and pass it
during the API call?

Thanks,
Anish



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Restlet-tp5767988p5770209.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Restlet

Posted by "anish.somadevan" <ne...@gmail.com>.
I have created a separate thread for the XML issue,

http://camel.465427.n5.nabble.com/Parsing-a-XML-in-DSL-td5770368.html

Can you please help me out? I shall delete the threads irrelevant to this
thread

Thanks,
Anish



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Restlet-tp5767988p5770369.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Restlet

Posted by "anish.somadevan" <ne...@gmail.com>.
Agree, my bad. I will create new discussion going forward. I will test this
and let you know if it worked for me. If not, then i shall create a new
thread and let you know on the same.

Thanks a lot for your help. Appreciate it.

Thanks,
Anish



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Restlet-tp5767988p5770366.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Restlet

Posted by "anish.somadevan" <ne...@gmail.com>.
Can you please help me with parsing an XML to get a node's value? Am trying
with xpath as given below

<xpath>/data/Provider()</xpath>

But this doesn't work. My input to a route is XML and i want to get a node's
value and route it based on it. I tried this

<xpath>${in.body}/data/Provider()</xpath>

But that didn't work either. 

Can you please let me know how to resolve this?

Thanks,
Anish



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Restlet-tp5767988p5770364.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Restlet

Posted by "anish.somadevan" <ne...@gmail.com>.
Am using JBOSS server. I have a question related to passing arguments to a
Javascript. In my route am calling a JavaScript this way,

<to uri="language:javascript:file:/generatetoken.js" />

Is there a way to pass arguments to this Javascript?

Thanks,
Anish



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Restlet-tp5767988p5770284.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Restlet

Posted by "anish.somadevan" <ne...@gmail.com>.
I was able to resolve the issue. It was due to a JAR which was conflicting
with a newer version JAR. After removing the old JAR I am able to send the
message to Rest API.

Thanks a lot for your help. Really appreciate it.

Thanks,
Anish



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Restlet-tp5767988p5770264.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Restlet

Posted by "anish.somadevan" <ne...@gmail.com>.
But i just noticed that when i have HTTPS and mention :443 as the port
number, i get the header missing error again. So basically the header is not
being set for some reason. But i don't understand why



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Restlet-tp5767988p5770261.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Restlet

Posted by "anish.somadevan" <ne...@gmail.com>.
Is there a difference in way it works in browser? Coz i see that when i
access the REST URL in browser i don't get any SSL errors coz of the CA
trusted certs the URL has. Do you reckon having .jks file in classpath is
the only way to access URL over HTTPS connection?

Thanks,
Anish



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Restlet-tp5767988p5770256.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Restlet

Posted by "anish.somadevan" <ne...@gmail.com>.
Although one concern i have is that if the certificate from Server is changed
in future then i have to import new cert. Can you let me know how to access
the keystore in route URI?  Is there any specific attribute to mention the
keystore?

Thanks,
Anish



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Restlet-tp5767988p5770233.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Restlet

Posted by "anish.somadevan" <ne...@gmail.com>.
Thanks for letting me know. Am fairly new to Camel. Should i place the
certificate in my Trusted certs directory, or should i handle it in my
route?

Also,Can you please provide me an example on how to use Camel-jetty for
invoking REST API?




--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Restlet-tp5767988p5770231.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Restlet

Posted by "anish.somadevan" <ne...@gmail.com>.
My connection was meant to be HTTPS but i was using HTTP in my URL. Now when
i change my URL to HTTPS, i get the following error,

 WARNING [org.restlet] (Restlet-69709808) Exception while writing the
message headers.: javax.net.ssl.SSLException: Unrecognized SSL message,
plaintext connection?

Can you let me know how to resolve this?

Thanks,
Anish



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Restlet-tp5767988p5770227.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Restlet

Posted by "anish.somadevan" <ne...@gmail.com>.
Also, i have another question on how to pass arguments to a Javascript  from
route. I have the following route,

 <route id="callTokenService">
        <from uri="direct:inter1" />
		<log message="Routing to Javascript" loggingLevel="INFO" />
<log message="Message body ${in.body}" loggingLevel = "INFO" />
		<to uri="language:javascript:file:/data/product/generatetoken.js" />

When i try to pass arguments to this Javascript (generatetoken(key).js), it
throws error saying file not found. The argument is being considered as a
file name here. Can you let me know how to pass arguments to a Javascript?

Thanks,
Anish




--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Restlet-tp5767988p5770216.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Restlet

Posted by "anish.somadevan" <ne...@gmail.com>.
This is the error message i get

04:25:01,428 INFO  [callRestAPI] (Camel (camelAgent) thread #2 -
JmsConsumer[ISEEOutboundQueue]) Routing to RestAPI
04:25:01,430 INFO  [callRestAPI] (Camel (camelAgent) thread #2 -
JmsConsumer[ISEEOutboundQueue]) Headers set in Javascript
{Authorization=MyToken,
Content-Type=application/atom+xml;type=entry;charset=utf-8}
04:25:01,861 ERROR [org.apache.camel.processor.DefaultErrorHandler]
(Restlet-910628961) Failed delivery for exchangeId:  Exhausted after
delivery attempt: 1 caught:
org.apache.camel.component.restlet.RestletOperationException: Restlet
operation failed invoking http://MyRESTAPI/public/messages with statusCode:
401 /n responseBody:<Error><Code>401</Code><Detail>MissingToken: The
authorization header was not found.
TrackingId:da04b482-9d16-4d71-8899-17c0df90d273_G22,TimeStamp:8/2/2015
8:25:02 AM</Detail></Error>:
org.apache.camel.component.restlet.RestletOperationException: Restlet
operation failed invoking http://MyRESTAPI/public/messages with statusCode:
401 /n responseBody:<Error><Code>401</Code><Detail>MissingToken: The
authorization header was not found.
TrackingId:da04b482-9d16-4d71-8899-17c0df90d273_G22,TimeStamp:8/2/2015
8:25:02 AM</Detail></Error>
	at
org.apache.camel.component.restlet.RestletProducer.populateRestletProducerException(RestletProducer.java:193)
[camel-restlet-2.10.3.jar:2.10.3]
	at
org.apache.camel.component.restlet.RestletProducer$1.handle(RestletProducer.java:93)
[camel-restlet-2.10.3.jar:2.10.3]
	at
org.restlet.engine.http.connector.BaseClientHelper.handleInbound(BaseClientHelper.java:714)
[org.restlet-2.0.5.jar:]
	at
org.restlet.engine.http.connector.BaseHelper.handleNextInbound(BaseHelper.java:418)
[org.restlet-2.0.5.jar:]
	at
org.restlet.engine.http.connector.Connection.readMessages(Connection.java:695)
[org.restlet-2.0.5.jar:]
	at org.restlet.engine.http.connector.Controller$2.run(Controller.java:95)
[org.restlet-2.0.5.jar:]
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
[rt.jar:1.6.0_45]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
[rt.jar:1.6.0_45]
	at java.lang.Thread.run(Unknown Source) [rt.jar:1.6.0_45]


And this is the route i use,

<route id="callRESTAPI">
        <from uri="direct:inter2" />
		<log message="Routing to RESTAPI" loggingLevel="INFO" />
<setHeader headerName="Authorization">
<simple>Sometokenvalue</simple>
</setHeader>
             <to uri="restlet"http://MYRESTAPI/public/messages"/>
	   <to uri="direct:inter3" />
    </route>

Can you please let me know what am missing here?

Thanks,
Anish



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Restlet-tp5767988p5770214.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Restlet

Posted by "anish.somadevan" <ne...@gmail.com>.
Yes, it is Authorization. I have tested it from a local REST client with the
same header, and that works fine. 
I just noticed that when i set the headers i get an error message saying
there are no consumers to process the message. But when i don't set the
headers i get the error of header missing



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Restlet-tp5767988p5770212.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Restlet

Posted by Gnanaguru S <gn...@gmail.com>.
This looks like, the API which you are calling is not expecting this header. 

Are you sure it is 'Authorization' ? It can be something else as well, like
X.Authorization. 

Otherwise I dont see an issue with the way you are setting the header. 

Cheers
Guru




--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Restlet-tp5767988p5770210.html
Sent from the Camel - Users mailing list archive at Nabble.com.