YOUR FEEDBACK
SOA Feature Story: Real-Time SOA Starts with the Messaging Bus!
Gerardo Pardo-Castellote wrote: Regarding the previous comment about "TCP ...
AJAXWorld RIA Conference
$300 Savings Expire July 25
Register Today and SAVE!

SYS-CON.TV
TOP THREE LINKS YOU MUST CLICK ON


Connect Non-SOAP HTTP Requesters and Providers to WebSphere Application Server V6 Enterprise Service Bus
WAS and ESB

Digg This!

Page 1 of 2   next page »

This article shows you how to connect non-SOAP HTTP service requesters and providers to the IBM® WebSphere® Application Server V6 Service Integration Bus. This lets requesters and providers leverage the integration capabilities of an enterprise service bus.

IBM's WebSphere Application Server V6 (hereafter called Application Server) provides a platform for building an Enterprise Service Bus (ESB). Building an Enterprise Service Bus with WebSphere Application Server V6, Part 1: Introduction to WebSphere V6 Messaging Resources is the first part of a series that provides a wealth of information on WebSphere Messaging Resources, also known as the Service Integration Bus, or SIBus, available in Version 6. The SIBus supports many of the integration features required of an ESB. The SIBus ships with mechanisms to connect service requesters and providers that use SOAP/HTTP and JavaTM Messaging Service (JMS).

However, there are many sources of service requesters and providers that don't use SOAP/HTTP or JMS. In this article, we'll talk about requesters and providers that use HTTP as a transport, but don't use SOAP, and may not even use XML as the payload. In some cases, such requesters and providers were developed before SOAP became widespread; in other cases, even for recently developed applications, SOAP is considered too heavyweight. See the Resources section for links to XML-RPC, REST, eBay-REST, eBay-XML and Yahoo to get a look at some non-SOAP mechanisms and applications that use them. Non-SOAP HTTP requesters and providers can be an important part of a service-oriented environment. In this article, you'll learn how to connect such entities to the SIBus. This allows non-SOAP HTTP requesters and providers to benefit from the same integration logic available for SOAP/HTTP and JMS requesters and providers.

Our goal
Figure 1 shows a scenario in which a service requester interacts directly with service a provider via XML/HTTP. This means that the requester uses an XML-encoded payload for the request message sent to the provider and expects an XML-encoded payload as the response message. The requester uses HTTP to deliver the request and receive any response.

Figure 2 shows the scenario we want to achieve, where a requester interacts with a service provider through an ESB that can, for example, log requests, modify requests, or even route requests to a different provider. You'll see later that the payload does not have to be XML.

Figure 3 shows some additional scenarios possible with an ESB. Integration logic in the ESB can transform requests so that XML/HTTP requesters can interact with SOAP/HTTP providers and SOAP/HTTP requesters can interact with XML/HTTP providers. However, in this article, we'll only deal with the scenario shown in Figure 2.

An analysis of the XML/HTTP <==> XML/HTTP scenario shows that the ESB must do the following:

  • Receive the XML/HTTP request from the XML/HTTP requester. (At this point, integration logic in a mediation can run to process the request.)
  • Send the request to the XML/HTTP provider
  • Receive the response from the XML/HTTP provider. (At this point, integration logic in a mediation can run to process the response.)
  • Return the response to the XML/HTTP requester
Our solution
Figure 4 shows an ESB topology that performs the steps described above. The figure shows a servlet that acts as an XML/HTTP on-ramp for the SIBus, in a manner very similar to the SOAP/HTTP on-ramp for Web services, called the inbound Web service, that ships with the SIBus. The servlet inserts the request into the SIBus, via the JMS sender, where it can be mediated if necessary, and returns the response to the requester, via the JMS listener. A Message-Driven Bean (MDB) acts as an XML/HTTP off-ramp for the SIBus, in a manner very similar to the SOAP/HTTP off-ramp for Web services, called the outbound Web service, that ships with the SIBus. The MDB sends the request to the XML/HTTP provider, via the HTTP client and inserts the response into the SIBus, via the JMS sender, where it can be mediated if necessary.

Note that to support the spectrum of possible non-SOAP request types, the ESB must preserve the fidelity of the HTTP request and response. In particular, the servlet must deal specifically with the following HTTP methods:

  • POST, where the requester sends body content in the request and expects body content in the response.
  • GET, where the requester only expects body content in the response.
  • PUT, where the requester sends body content in the request, but expects no body content in the response.
  • DELETE, where the requester sends no body content in the request, and expects no body content in the response.
In addition, the servlet's JMS sender function inserts the HTTP method, the HTTP path info (part of the URL past the root), the HTTP parameters and the HTTP headers (including cookies) from the HTTP request into a JMS message inserted into the SIBus. For the POST and PUT methods, the JMS sender also inserts the request payload or body (which might be XML) into the JMS message. The JMS sender then sends the message to an SIBus queue destination (the yellow box labeled Request in Figure 4). The servlet then invokes its JMS listener to listen for the response.

The MDB listens for messages arriving on the Request queue. Upon receiving a message, the HTTP client function of the MDB constructs an HTTP request using all the information placed in the request JMS message by the servlet. There is one significant semantic difference between the newly constructed HTTP request and the original HTTP request received by the servlet: the root URL is different so that when the HTTP client sends the request, it goes to the expected provider. The MDB HTTP client waits for the synchronous HTTP response from the provider.

The MDB JMS sender inserts any response payload, the HTTP headers (including Set-Cookie headers) and status code from the HTTP response into a JMS message. The JMS sender also sets the correlation ID of the JMS response message to the message ID of the JMS request message, and then sends the JMS response message to an SIBus queue destination (the yellow box labeled Reply in Figure 4).

The servlet's JMS listener listens for an incoming message on the Reply queue with a JMS selector set to match a response correlated with the request; the correlation ID of the response must be equal to the JMS request message ID. Upon receiving the correlated response message, the JMS listener inserts only the response status code into the HTTP response if the response is not OK. If the response is OK, the JMS listener inserts the response (XML) payload and any headers from the JMS message into the HTTP response. The JMS listener then returns the HTTP response to the original requester.

Implementation
Listing 1 shows the servlet skeleton used for the on-ramp. The init() method gets the JMS connection factory and queues, and starts a connection. The connection is held open for the lifetime of the servlet, and is not closed until the servlet's destroy() method gets called. Configuration information, such as JNDI names, is described in detail in the next section.

Listing 1. Servlet skeleton


public class XMLHTTP2SIB extends javax.servlet.http.HttpServlet
implements javax.servlet.Servlet {

// connection factory and queue resources
private final static String

JMSCF_JNDI_NAME = "java:comp/env/MDBCF";
private final static String JMSRequest_JNDI_NAME =

"java:comp/env/MRequest";
private final static String

JMSReply_JNDI_NAME = "java:comp/env/MReply";
// session and connection
private Session session = null;
private Connection connection = null;
// request and reply queues
private Destination requestQueue = null;
private Destination responseQueue = null;


public void init() throws ServletException {

try {

InitialContext context = new InitialContext();

ConnectionFactory factory = (ConnectionFactory)

context.lookup(JMSCF_JNDI_NAME);
requestQueue = (Destination)

context.lookup(JMSRequest_JNDI_NAME);
responseQueue = (Destination)

context.lookup(JMSReply_JNDI_NAME);

connection = factory.createConnection();

session = connection.createSession(

false,

Session.AUTO_ACKNOWLEDGE);


connection.start();

} catch (NamingException e) {

...

} catch (JMSException e) {

...

}
}

public void destroy() {

try {

connection.close();

} catch (JMSException e) {
...

}
}
}


Page 1 of 2   next page »

About Greg Flurry
Greg Flurry is a member of the IBM Software Group Emerging Technologies area. His current responsibilities include introducing web services techologies into the IBM WebSphere product family.

Rob Lee wrote: Where can I find the XMLHTTPUtil class?
read & respond »
Rob Lee wrote: Where can I find the XMLHTTPUtil class?
read & respond »
Rob Lee wrote: Where can I find the XMLHTTPUtil class?
read & respond »
SYS-CON Belgium News Desk wrote: This article shows you how to connect non-SOAP HTTP service requesters and providers to the IBM® WebSphere® Application Server V6 Service Integration Bus. This lets requesters and providers leverage the integration capabilities of an enterprise service bus.
read & respond »
WEBSPHERE LATEST STORIES . . .
WSRP Really Works! - Part 2
A standard from OASIS called Web Services for Remote Portlets (WSRP) is used so portlets can be decoupled from a portal. In part one (JDJ, Volume. 13, issue 3) of this article, we introduced the relevant standards and specifications and then demonstrated WSRP's capabilities by consumin
Adobe's Kevin Lynch and Microsoft's Scott Guthrie to Keynote AJAX World RIA Conference & Expo
Two of the biggest launches in Rich Internet Application history took place in 2007/2008 when Adobe launched AIR 1.0 in February '08 and Microsoft launched Silverlight (September '07). At the 6th International AJAXWorld RIA Conference & Expo in October SYS-CON Events is delighted to be
MyEclipse 6.5 Blue Edition: Next-Generation ALM and Open Source Development for WebSphere
Genuitec announced the availability of MyEclipse 6.5 Blue Edition; a next-generation ALM and open source-friendly IDE for WebSphere. Of note, users will be drawn to multiple technologies not currently supported by IBM's RAD, such as Maven4MyEclipse (a professional implementation of Mav
ZSL Launches Enterprise 2.0 Computing Framework Built on IBM WebSphere sMash
ZSL announced its Enterprise 2.0 Computing Framework built on IBM WebSphere sMash and Service Oriented Architecture (SOA). ZSL's new Enterprise 2.0 computing framework offerings will enable businesses to protect core legacy system investments while leveraging cutting-edge tools and dev
Free Guest Passes for the SOA World Conference & Expo in New York City
SYS-CON's upcoming '3rd International Virtualization Conference & Expo' faculty includes such distinguished speakers as: Al Aghili (Managed Methods), Alan Chhabra (Egenera), Andi Mann (Enterprise Management Associates), Andrew Conte (APC), Andy Astor (EnterpriseDB), Ariel Cohen (Xsigo
Microsoft's Virtualization Chief Mike Neil To Keynote SYS-CON's Virtualization Conference & Expo
Mike Neil is general manager for virtualization strategy in the Windows Server Division at Microsoft. Mike is focused on the delivery of the Windows virtualization technology, including Windows Server 2008 Hyper-V, Microsoft Hyper-V Server and Virtual PC 2007. Mike also directs the tec
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS
SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021

SYS-CON FEATURED WHITEPAPERS

ADS BY GOOGLE
BREAKING WEBSPHERE NEWS
*Revised* Analyst Reports for International Business Machines Corporation, Barr Pharmaceuticals Inc., The Home Depot Inc., and Schlumberger Limited
MaybachFinancial.com is one of the fastest growing independent and unbiased research firms i