5 Replies Latest reply on Nov 18, 2008 9:47 PM by scottdawson

    JBR-HTTP provider

      Hello,

      I'm trying to use JBR-HTTP provider for handling POST requests arriving from the external C++ application. Somehow these requests are simply not being handled - complete silence on the side of ESB upon sending these requests from my application.

      At the same time - GET requests are being handled normally.

      For preventing any possible guesses regarding the bugs in C++ libraries, I wrote a simple Java application, which tries to send POST requests. Result is the same - silence upon sending POST requests and normal behavior upon GET requests.

      Am I missing something? Actually this is my first project with JBoss ESB, so I do not know that much about everything here...

      Java-side code for the testing purposes looks like this:

      URL serverUrl = new URL("http://localhost:8888");
      HttpURLConnection serverConnection = (HttpURLConnection)serverUrl.openConnection();
      serverConnection.setDoInput(true);
      serverConnection.setDoOutput(true);
      serverConnection.setUseCaches(false);
      serverConnection.setRequestMethod("POST");
      serverConnection.setRequestProperty("Content-Type", "text/xml");
      serverConnection.setRequestProperty("Content-Length", Integer.toString(testString.length()));
      serverConnection.connect();
      
      OutputStreamWriter out = new OutputStreamWriter(serverConnection.getOutputStream(), "UTF-8");
      out.write(testString);
      out.flush();
      out.close();
      



        • 1. Re: JBR-HTTP provider

          P.S.: I'm using ESB v4.4 and AS v4.2.3.

          • 2. Re: JBR-HTTP provider

            One more P.S. from my side...

            Originally I was planning to send XML data from my C++ application via plain sockets and not via HTTP requests. After finding out that JBR-Socket provider is not that much straightforward in terms of its services... I've decided to stick with XML over HTTP.

            Actually it's really disappointing that the client-side logic talking to ESB also have to be compliant with JBR specifics... Shouldn't it be "ESB Unaware" according to the documentation from this site? And there are no options in JBoss ESB for connecting such a simple thing as C++ application sending a really simplistic XML payload via regular sockets.

            According to my understanding the whole idea about ESB rotates around the following core concepts:

            1) Transparent decoupling and integration of the heterogeneous systems
            2) Abstraction from the integration logic - so the developer will be able to focus on the business logic development

            Am I correct?

            My opinion is that the last concept is the main value (in theory) of ESB.
            But at the same time, my current experience shows the opposite...

            I'm still thinking about the following remaining options:

            1) Using MINA transports via integrating Apache Camel into JBoss ESB - there is an article regarding this topic.

            2) Developing my own JCA adapter... though the necessity of ESB will be put under a question mark for this case.


            Sorry for all this additional lyrics... I'm just trying to present all the details of my problem.

            • 3. Re: JBR-HTTP provider
              scottdawson

              Oleg,
              I made a few adjustments to your Java code and was able to POST through a JBR-Http listener. I've written clients in JavaScript and Python to do the same thing so I don't think the implementation language of the client makes any difference.
              Try this:

               String testString = "<tag>my data</tag>";
               URL serverUrl = new URL("http://localhost:8765");
               HttpURLConnection serverConnection = (HttpURLConnection)serverUrl.openConnection();
               serverConnection.setDoInput(true);
               serverConnection.setDoOutput(true);
               serverConnection.setUseCaches(false);
               serverConnection.setRequestMethod("POST");
               serverConnection.setRequestProperty("Content-Type", "text/xml");
               serverConnection.setRequestProperty("Content-Length", Integer.toString(testString.length()));
              
               OutputStream out = serverConnection.getOutputStream();
               out.write(testString.getBytes());
               out.close();
              
               int responseCode = serverConnection.getResponseCode();
               System.out.println("Response code = " + responseCode);
              


              Regards,
              Scott


              • 4. Re: JBR-HTTP provider

                Hi Scott,

                Many thanks for your help, these small changes have really solved the problem!

                But at the same time - I have one small observation about JBR-HTTP behavior...
                JBR-HTTP wakes up only upon performing some read operations on the client side,
                so when doing some write-only operations without reading anything, ESB remains silent...

                You've added the following chunk of code for reading the response code:

                int responseCode = serverConnection.getResponseCode();
                System.out.println("Response code = " + responseCode);
                


                After some debugging I saw that ESB becomes alive only after reaching the line about reading the status code.
                And the whole point here is not about reading the status code - it is about any kind of read operation from the input stream on the side of client application.

                Again - is this an expectable behavior of JBR-HTTP?

                Thanks in advance for your help.

                • 5. Re: JBR-HTTP provider
                  scottdawson

                  Oleg,
                  You are right, the ESB doesn't see any request until you call some type of "get" method on HttpURLConnection (getInputStream, getResponseCode, getContent), but that is because of the behavior of the HttpURLConnection class, not the JBR-Http listener. The HttpURLConnection is not sending the HTTP request until you call one of those methods. The HTTP protocol doesn't really have a "read" operation. It only defines request messages and response messages. So the ESB doesn't respond till HttpURLConnection sends the HTTP request message and that only happens when you call one of the HttpURLConnection "get" methods.

                  Regards,
                  Scott