-
1. Re: JBR-HTTP provider
oleg_p Nov 17, 2008 3:14 PM (in response to oleg_p)P.S.: I'm using ESB v4.4 and AS v4.2.3.
-
2. Re: JBR-HTTP provider
oleg_p Nov 17, 2008 4:23 PM (in response to oleg_p)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 Nov 17, 2008 10:37 PM (in response to oleg_p)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
oleg_p Nov 18, 2008 6:50 AM (in response to oleg_p)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 Nov 18, 2008 9:47 PM (in response to oleg_p)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