Web services are ubiquitous. I love to develop with third-party web services and incorporate them into my web applications. They can add great functionality with minimal effort.
I am have written a step by step guide to setting up a web application which uses a third-party web service. The application will show the live price details of a stock in a popup window when the mouse hovers over the stock’s code.
I start by creating the web service client using Eclipse’s Web Service Client Wizard. This sends a SOAP message to the web service with a stock code as its payload and receives in response live stock price data in XML format.
Next I marshal the XML to a Stock object using JAXB. By doing this it becomes more convenient to manipulate the data later on.
To create the popup I use a JSP template and standard tag libs to manipulate the data. This is then dispatched to the client in a servlet response.
The popup is display in response to the mouse hovering over the stock’s code. The mouse over event triggers an AJAX call (jQuery) to the servlet which returns an HTML string containing the stock price data (generated from the JSP template). Then using jQuery the HTML string is put in the popup.
The steps are as follows: