|
|
YOUR FEEDBACK
Did you read today's front page stories & breaking news?
SYS-CON.TV |
TOP THREE LINKS YOU MUST CLICK ON Application Management
Connect Non-SOAP HTTP Requesters and Providers to WebSphere Application Server V6 Enterprise Service Bus
WAS and ESB
By: Greg Flurry
Jan. 27, 2006 09:45 AM
Digg This!
Page 2 of 2
« previous page
Before describing the servlet request and response processing logic, let's discuss the utility class HTTPOutput, partially shown in Listing 2 below. This class is used to convey information from the HTTP response. It has a returnCode field that carries the HTTP response status. The header field contains any response headers, where each member in the Vector is a two-element array of String; the first member of the array is the header name and the second is the header value. The utility class also contains the body in the response field. Note that only the returnCode field is guaranteed to be meaningful; the others can be null. Listing 2. HTTPOutput class Listing 3 shows the servlet's doPost() method. The method first uses the private sendJMSMessage() method to map the HTTP request into a JMS message and insert that message into the SIBus, as shown below. Note that sendJMSMessage() returns the ID of the message to use in a JMS selector; this helps correlate the response to the request. doPost() then listens for the response on a JMS queue by calling the private getJMSResponse() method; as shown below. If doPost() finds that the status code from the response indicates that request was unsuccessful, it simply returns the status code; otherwise it returns the entire response body and headers. This ensures the response returned to the original requester semantically matches that returned by the actual provider. Note that header names require a bit of special processing using the utility function XMLHTTPUtil.unfixName(), because JMS properties are used to send the HTTP headers in the response JMS message, and Java does not allow the dash character to appear in JMS property names. The use of the dash is common in HTTP header names, and a companion utility function, XMLHTTPUtil.fixName() used in the MDB that sends the response, replaces any dash characters in a name with underscore characters, as you'll see later. Listing 3. The servlet's doGet(), doPut() and doDelete() methods all simply call the doPost() method described above. The sendJMSMessage() method deals with the differences in the request for the various HTTP methods (POST and PUT have body content, GET and DELETE don't), and as you can see, the doPost() method itself deals with the differences in the response for the various HTTP methods (POST and GET have body content, PUT and DELETE don't). Page 2 of 2 « previous page
WEBSPHERE LATEST STORIES . . .
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
|
SYS-CON FEATURED WHITEPAPERS MOST READ THIS WEEK BREAKING WEBSPHERE NEWS
|
|||||||||||||||||||||||||||||||||||||