Announcement Announcement Module
No announcement yet.
Sending requests to fetch information to https://URL Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Sending requests to fetch information to https://URL

    Hi All,

    I am new to using http adapters in SI. I am trying to sending a request to a URL that runs on only secured protocol i.e., 'https'. I have tried a lot a lot but not able to establish a connection to the URL.

    I have tried using a proxy even but the connection is not established to the URL. Looking for some help from the group members on how to establish connection to a URL using http adapters.

    Here is my configuration code:

    <beans:bean id="httpDemo" class="blog.HTTPDemo" />
    <int:channel id="requestChannel" />
    <http:outbound-gateway request-channel="requestChannel" reply-channel="httpResponseChannel" auto-startup="true" url="" />
    <int:channel id="httpResponseChannel" />
    	<!-- <int:queue capacity="10" />
    </int:channel> -->
    <int:service-activator input-channel="httpResponseChannel" ref="httpDemo" />
    Thanks in Advance!!!

    Avinash Munaga.

  • #2
    You need to look at the logs and/or what's going on "on the wire"; https just "works" because it is handled by the JVM.

    For example, if you look at the basic/http sample here

    just change the URL to an https one and you'll see it just works.

    <int-http:outbound-gateway request-channel="requestChannel" 
    If you run a line monitor, like wireshark you can see all the SSL/TLS handshaking happening.

    If you can't figure it out from debug level logs, try running wireshark - you won't be able to read the data, but you should at least see the socket establishment.


    • #3
      Hi Avinash,

      are you sure that connection is not established? Do you see error in log? I tried your sample and response is 400: Bad request - which is OK since I don't know required POST/GET params for this URL. But fetching works fine. Btw. how do you send messages to requestChannel?


      • #4

        Thanks for the replies.

        I am trying to send request like this.

        ApplicationContext context = new ClassPathXmlApplicationContext("config-http.xml");
        JSONObject json = new JSONObject();
        //creating JSON
        Message<?> message = MessageBuilder.withPayload(json.toString()).build( );
        context.getBean("requestChannel", MessageChannel.class).send(message);
        But, it's not working. Even tried sending request to integration in a different way like this:

        ApplicationContext context = new ClassPathXmlApplicationContext("config-http.xml");
        JSONObject json = new JSONObject();
        //creating JSON
        Message<?> message = MessageBuilder.withPayload(json.toString()).build( );
        ChannelResolver resolver = new BeanFactoryChannelResolver(context);
        MessageChannel channel = resolver.resolveChannelName("requestChannel");
        This is the error message while sending request in both the cases.

        WARNING: POST request for "" resulted in 400 (Bad Request); invoking error handler
        Exception in thread "main" org.springframework.integration.MessageHandlingExc eption: HTTP request execution failed for URI []
        at org.springframework.integration.http.outbound.Http RequestExecutingMessageHandler.handleRequestMessag e(
        at org.springframework.integration.handler.AbstractRe plyProducingMessageHandler.handleMessageInternal(A
        at org.springframework.integration.handler.AbstractMe ssageHandler.handleMessage(AbstractMessageHandler. java:73)
        at org.springframework.integration.dispatcher.Unicast ingDispatcher.doDispatch( :114)
        at org.springframework.integration.dispatcher.Unicast ingDispatcher.dispatch( 01)
        at bscribableChannel.doSend(AbstractSubscribableChann
        at ssageChannel.send(
        at ssageChannel.send(
        at blog.HTTPDemo.main(
        Caused by: org.springframework.web.client.HttpClientErrorExce ption: 400 Bad Request
        at org.springframework.web.client.DefaultResponseErro rHandler.handleError(DefaultResponseErrorHandler.j ava:76)
        at org.springframework.web.client.RestTemplate.handle ResponseError(
        at org.springframework.web.client.RestTemplate.doExec ute(
        at org.springframework.web.client.RestTemplate.execut e(
        at org.springframework.web.client.RestTemplate.exchan ge(
        at org.springframework.integration.http.outbound.Http RequestExecutingMessageHandler.handleRequestMessag e(
        ... 8 more

        How are you guys sending message to the request channel. Could you please share some sample code that work's.

        Thanks in Advance!!!
        Last edited by AvinashMunaga; Mar 8th, 2012, 02:16 AM.


        • #5
          This looks like rather problem during authentication, not connection problem of SI. You should check that all of required authentication parameters are set. Also, while I didn't work with OAuth, I think that you should use POST request:
          <int-http:outbound-gateway http-method="POST"...