Samples


Several examples of use have been included in the "samples" folder (if you did not get a "samples" folder when you extracted these files, please download the latest version of this library). These include:

StockQuote
This example gets a delayed stock quote, based on a stock symbol that you pass to it. It's probably the simplest example, because there's a single String parameter to send, and it returns a single number, but it's the best one to start with to see how to make basic calls.

ZipCodeTest
This is just as simple as the StockQuote example, but it passes a zip code String and returns the city that corresponds to that zip code.

InteropEchoString
This example calls a web service that simply echos back a string you send to it. However, the service I chose does not specify a namespace in the SOAP response message (which is common with Microsoft web services), so this sample is a good example of how to use the addReturnDatatype method to deal with this situation.

WeatherReportTestXML
This starts to get a little more interesting, because the weather service that we call returns a complex data type that nests several other complex data types. The easiest way to deal with this situation is to use an XmlNodeDeserializer to translate the return value into a raw XML node, and then parse it appropriately. In this case, we just walk through the nodes and print everything out to the console, but in practice you'd be looking through the nodes for specific bits of information. It does show how easy it can be to get complex return values though, if you don't mind getting them as XML.

WeatherReportTestComplex
This is similar to the WeatherReportTestXML example, but the weather information returned by this call is a little easier to deal with. What we did here was model the complex return value as a Java bean (with the WeatherSummary class, which is pretty straightforward if you take a look at it), add this class as a complex data type with a call to addComplexDatatype, and then call the method as we did in all the other examples. Because we registered the WeatherSummary class and it matches the structure of the return value, we end up with an instance of WeatherSummary as a response to our call.