This is a web service that, given a language preference, looks up the latest news from Yahoo! and displays it in the language of choice. So what's so special about it?
The key is that this web service has been developed as a composition of other web services, using the recently released Business Process Execution Language for Web Services (BPEL4WS) specification. Stated simply, BPEL4WS is a new standard for composing Web services and exposing such compositions as Web services. For introductions to the BPEL4WS language, take a look at the references section of this document. This example makes use of two Web services available at xmethods.com. The first is the Headline News service, available from SQLData, and the second is the BabelFish service, available from XMethods.
The basic idea behind the example is that we would like to combine the functionality of these two service to create a composite service that provides the latest news in a language of the user's choosing. To do this, we write a BPEL4WS process, describing how we receive the input parameter (language preference) from the user, invoke the news service to get the latest news, then use BabelFish to translate this into the language of choice. One complication here is that the Headline News service delivers the news as HTML text, while BabelFish translates plain English text. So we wrote a utility java class that strips off HTML tags from text input. We then invoke this class to convert HTML-ized text into plain English text. The output of this invocation is fed to BabelFish, and the result obtained from BabelFish is returned to the user of our composite Web service. The flow of data and control is illustrated below. The entire process is offered to the user as a Web service with a single operation, getNews, that takes a language preference as input and returns the translated news as output.
There are two points worth highlighting:
This example works by using IBM's alphaworks implementation of the BPEL4WS specification, BPWS4J as the runtime engine. This engine can executes BPEL4WS processes, given the process definition, the definition of the process' external interface (how clients view it) and the WSDLs for all the Web services that the process uses. In our example, here are the relevant files:
Note that the Headline News service and BabelFish service descriptions come from external sources. The HTML2Text service is a local java class deployed on the same server running the BPWS4J engine (which also serves up this web page) but has been developed completely independently.