Creating a Web Service Client with Delphi - Behind the scenes
(Page 4 of 4 )
So what is happening behind the scenes when you execute the code? Well, the HTTPRIO component creates a SOAP envelop and sends this off to the web service server, which in turn processes the message and returns an appropriate response. The messages, both outgoing and incoming, are in XML format:
Outgoing message:
<?xml version="1.0"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd=http://www.w3.org/2001/XMLSchema
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><SOAP-
ENV:Body>
<GetWeatherByPlaceName xmlns="http://www.webservicex.net">
<PlaceName>london</PlaceName>
</GetWeatherByPlaceName>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
You can clearly see the place name parameter that we entered. In this case it is London. Below is the response message we get from the web service server:
Incoming message:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope
xmlns:soap=http://schemas.xmlsoap.org/soap/envelope/
xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetWeatherByPlaceNameResponse xmlns="http://www.webservicex.net">
<GetWeatherByPlaceNameResult><Latitude>30.6171017</Latitude>
<Longitude>99.62553</Longitude>
<AllocationFactor>2.7E-05</AllocationFactor>
<FipsCode>48</FipsCode>
<PlaceName>LONDON</PlaceName>
<StateCode>TX</StateCode>
<Details><WeatherData>
<Day>Sunday, August 13, 2006</Day>
<WeatherImage>http://www.nws.noaa.gov/weather/images/fcicons/
nscttsra10.jpg
</WeatherImage>
….
</soap:Body>
</soap:Envelope>
The Delphi SOAP framework does all the hard work of putting together the SOAP envelope and sending it off to the server; then it reads the response and converts the XML into a human readable form.
Conclusion
In this article we went through the process of building a web service client and also discussed the various components and methods needed to make an application work. In the next article we are going to create a web service from scratch and also create a client that will enable us to use the service.
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |