Creating a Web Service Client with Delphi
(Page 1 of 4 )
In this article, the second of three parts covering web services, we will build a web service client and discuss the various components and methods needed to make an application work.
A downloadable file for this article is available
here.
In the previous article we learned what a web service is and examined the kind of code used to create one. We also looked at some actual WSDL, XML and SOAP code. In the second part of the "Web Services Made Easy" series we are going to create a web service client for an already existing web service, and then we are going to create our own simple web service and client with Borland Delphi. This is because I want you to see how easy it is to access a web service that is already built by someone else in a different programming language. We will create our own custom web service because in this way you will learn how to create your own methods for the web service and also how to access them. Since we’ve done a lot of theoretical work in the first part, I feel it is time to demonstrate everything we discussed, in practice.
Building a web service client
The first client we are going to create is going to be a service that will give us the weather forecast for international cities such as London or Paris. So open up your web browser and go to http://www.xmethods.com/. There you will see a complete listing of all the web services that are available, as well as what programming language was used to create them.
Click on the link that says "View full listing" and then press "ctrl + f" to bring up the find dialog box (I.E. browsers only). Type in "USA Weather Forecast" and then click on "find next." This should take you straight to the "USA Weather Forecast" link. Click on the link and then find the label that says "WSDL." Copy the link next to it. Now start Delphi, go to File|New|Other, and then click on the web services tab. You should now see a dialog like this:

Click on the WSDL importer icon. You should now see the following screen:

Enter the link you copied and click on "next." You should now see the following screen:

Click on "finish" and Delphi will create a unit called "Weatherforecast" for you. Save the unit. We'll take a look at the unit's code listing in the next section.
Next: Code Listing >>
More Delphi-Kylix Articles
More By Leidago