1
votes

I want to send https consumer request using camel-jetty component and that address returns some response in JSON format, below I mention my DSL code.

from("jetty:https://someSiteAddress.com/api/control/authorizeUser?username=__&password=__").to("stream:out"); 

I am getting this warning:  
[WARNING]   
java.net.SocketException: Permission denied  
at sun.nio.ch.Net.bind0 (Native Method)  
at sun.nio.ch.Net.bind (Net.java:433)
at sun.nio.ch.Net.bind (Net.java:425)
at sun.nio.ch.ServerSocketChannelImpl.bind 

But whenever I hit this HTTP URL in browser it will execute perfectly with authentication.
If anyone knows what to do to perform this action in apache camel please help me it will be very cheerful for me and others.

And how could I know which method camel using for sending a request like POST or GET.
Thank You

2
Hi! If I understand correctly, you want to consume this endpoint: https://someSiteAddress.com/api/control/authorizeUser?username=__&password=__, correctly? If I'm right, you should use the camel-http component in to. The way your code is described, you are exposing the URL, not consuming it. If you're having troubles with it, let me know that I put it in a answer. - Ricardo Zanini
@RicardoZanini Thank You for helping, Let me specify clearly Here I want to hit endpoint: from("mention above") which is return some token_Id's and these token_Id's I am printing on console by to("stream:out"). But I am getting above error and I think this error because of jetty. - Rajat.r2
Hi! please, see my answer. The way you are using jetty is to expose a endpoint at this address: https://someSiteAddress.com not consuming from it. To consume from an url you have to specified it using to(). - Ricardo Zanini

2 Answers

1
votes

Could you try this instead? I'll comment each line to help understand your problem.

// endpoint to start your route. could be a http endpoint you expose via jetty, jms, vm, seda or any other option. Here I'm using the simplest one.
from("direct:start")
    // logs on
    .to("log:DEBUG?showBody=true&showHeaders=true")
    // consume the endpoint
    .to("https://someSiteAddress.com/api/control/authorizeUser?username=__&password=__"")
    // log the body to the console so you could process the response later knowing what to do (the token you are mentioning should be in here.
    .to("log:DEBUG?showBody=true&showHeaders=true")
    .to("stream:out") //or whatever you want to

Don't forget the camel-http dependency for this example to work:

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-http</artifactId>
</dependency>

Cheers!

0
votes

This is also working fine.

  from("direct:in")
 .to("https://www.someAddress.com/api/control /authorizeUser?username=__ &password=__")
 .to("stream:out");

Thanks @RicardoZanini