Download CD Content
The code in previous chapters centers on simple examples, such as the SimpleStockQuote, to examine how the technology works rather than the practical application of Web Services. This chapter demonstrates a more complicated Web Service that returns different types and contains more than one method. This helps show you how to return various types of variables such as a float or string. There are some subtleties here. Additionally, this chapter allows you to review several of the subjects covered in the second half of this book such as security and creating proxies for Java code.
The examples here focus on a service that converts U.S. dollars into foreign currency, and the sections in this chapter take a four-stage approach to engineering this service, including: design, develop, test, and deploy. In the design stage, you consider the requirements for the service such as security and platforms supported. In the development stage, you write the code to meet the requirements that were originally set. The testing stage allows you to test the code you created in the development stage. This is usually the time when management adds more requirements that push you back into development for a little longer. The deployment stage involves configuring the hardware and networking necessary to implement the Web Service.
In the design stage, a development team gathers requirements from the user base. In this example, users need a currency exchange system that converts money into certain foreign denominations, converts foreign money into dollars, and returns the name of a particular currency. The example covered in this chapter does all this for money from Argentina, Australia, China, Japan, Switzerland, Mexico, and the UK.
Another consideration is to determine the platform from which to execute your Web Services. Should it be a Java-based or .NET Web Service? Luckily, the fact that Axis and .NET create WSDL that both utilize to create proxies for their clients gives you a lot of flexibility when making this decision. It really depends on the hardware, software, and development talent that’s available to you. Java is a more mature language and seems less prone to the annoying bugs that C# occasionally has, but as Microsoft releases Solution Packs™ many of these bugs will disappear and .NET will be more stable. Support may be another consideration when choosing a technology. .NET has Microsoft’s huge infrastructure of support teams and developers standing behind their products whereas with Apache products you need to post a message to a news group with the hopes that someone replies. Although there are plenty of supported Java-based Web Service implementations available from companies such as Cape Clear Software or BEA Systems.
The exchange rates normally need to be dynamic, such as a call to a database, but for the sake of simplifying the example, the exchange rates will be hard coded.
Once you gather the programmatic requirements, you need to consider the consumers using your services. Are the consumers applications? Or are they Web pages? Or both?
This example assumes that your user wants both Web pages and applications, and this decision directly affects how you test the Web Service because you need to test both.
Once you’ve gathered all these requirements, you’re ready to begin development.