5 Replies Latest reply on Jul 15, 2013 12:50 PM by synclpz

    HTTP GET with parameters

    synclpz Novice

      I am trying to implement some service in SwitchYard, evaluating how it can be integrated into existing infrastructure. For instance, existing infrastructure service is an http-based service, which consumes GET requests and returns xml-based body in response.


      So, I am trying to implement this in SY:


      <<Web-Service binding>> --> <<Bean Service to implement mapping or other actions>> --> <<Some kind of HTTP-reference to existing infrastructure service>>


      WS-interface and bean are ok. But! Existing http-service is accessed via request - http://<url>:<port>/<path>?action=<some action>&login=<some login>&password=<some password>&params=<some params>


      As I found exploring SY sources, its HTTP-binding allows only "fixed" GET requests (i.e. configured URL in switchyard.xml), but I need parameterized. I explored some materials (and asked questions in different thread) about how to make custom reference binding, and was pointed to use Camel-components, then integrate with SY. Then found article (https://community.jboss.org/wiki/SwitchYardAS7CamelIntegration) and successfully integrated camel-http4 into SY.


      Now I don't know how to achieve my goal of sending http-get with parameters. As I see it from Camel docs, it could be achieved by putting some specific "headers" to Camel Context, but I don't know how can I put some data from my data-exchange-beans to camel headers.


      Please, help me find the way out anyone :-) May be it is all wrong what I do?

        • 1. Re: HTTP GET with parameters
          Keith Babo Master

          For fine-grained control over the HTTP interaction, going with the Camel HTTP component is a reasonable approach.  It would not be particularly difficult to add this capability to our HTTP gateway in the box, so feel free to log a JIRA requesting that feature if you like.


          Setting the headers for the Camel HTTP component can be done via message context properties in SY.  Unfortunately, for 1.0 you are going to hit this limitation with a Bean service performing the invocation:



          That will be fixed for 1.1.  In the meantime, you could use a Camel routing service and just use <setHeader> in the route.

          1 of 1 people found this helpful
          • 2. Re: HTTP GET with parameters
            synclpz Novice

            Ok, I've also found this method - setting header via camel service. That's good I'm on the right way.


            I'll try to setup the following scenario:


            <SCA binding> --> <Camel Impl> --> <Camel http4-reference>


            1. SCA binding receives some, for example, HttpRequestBean with URL, params, HTTP-headers, cookies etc.

            2. Camel service implementation invokes several setHeader(), according to bean's fields

            3. http4-reference sends HttpRequest, receives HttpResponse, but what happens then?


            How can response be parsed and converted to some HttpResponseBean to return through SCA binding?

            • 3. Re: HTTP GET with parameters
              synclpz Novice

              Got this working, sending HTTP-GET requests, but can't find the way to deal with response from server. Seems like camel-route component can only process in-only message flow. Is there a way to make response available?

              • 4. Re: HTTP GET with parameters
                Keith Babo Master

                Post the route please.

                • 5. Re: HTTP GET with parameters
                  synclpz Novice

                  Sorry, removed this project already. It was something like this:


                  from("switchyard://HttpService").removeHeaders(".*").setHeader(Exchange.HTTP_URI, simple("$body.uri")).to("switchyard://HttpServiceRef");


                  where HttpService is something like


                  interface HttpService {


                       HttpResponseBean performGet(HttpRequestBean data);




                  HttpServiceRef is also this interface, but with camel-http4 binding.


                  At the moment I try to extend http-component of SY to parse headers and use provided "url" instead of baseUrl, specified in OutboundHandler and then put needed header to Exchange context via custom MessageComposer and ContextMapper