1 Reply Latest reply on May 18, 2012 11:10 AM by Vatsan Madabushi

    Looking for REST client example

    Gregory Khrapunovich Newbie

      I am trying to write C# code that communicates with HornetQ via REST. I started HornetQ Server locally. Unfortunately my post asking for specific queue returns an exception "(405) Method not allowed". (As a prototype I used sample code for accessing Yahoo REST interface that I found on the web. It worked with Yahoo).

       

      I understand that nobody in this community uses C#, but do you have any examples of REST clients in any language? I could not find them in HornetQ distribution.

        • 1. Re: Looking for REST client example
          Vatsan Madabushi Novice

          here is an example using Java and SpringFraemWork 3.1  RestTemplate

           

           

           

           

           

           

           

           

           

           

           

           

           

           

           

          public

           

          static void

          callScheduleManager(String schedulerXML)

          {

          String func =

          "callScheduleManager"

          ;

          RestTemplate client =

          new

          RestTemplate();

          String url =

          "http://127.0.0.1:8080/QuartzApp/ScheduleManager/schedule/manage/"

          ;

          String request =

          "This needs to be an XML"

          ;

          List<HttpMessageConverter<?>> messageConverters =

          new

          ArrayList<HttpMessageConverter<?>>();

          messageConverters.add(

          new

          FormHttpMessageConverter());

          messageConverters.add(

          new

          StringHttpMessageConverter());

          client.setMessageConverters(messageConverters);

           

           

          try

          {

          String response = client.postForObject(url, request, String.

          class

          );

          System.

          out.println("RestClient response is - "

          + response);

          }

           

          catch

          (RestClientException e)

          {

          e.printStackTrace();

          System.

          out.println(func + "client barfed"

          );

          }

          }