Webservice Client and Server Demo in PHP - CodeProject
Webservice Client and Server Demo in PHP - CodeProject
Introduction
This article demonstrates how different webservices work. The article is for beginners so the source code is kept simple. The source code contains 6 different webservice clients and 2 webservice servers. All examples are programmed in PHP 5, so they run on Windows and Linux. Some samples send the requests via GET and others use POST. Some samples send the requests via URL and others use SOAP. The code does NOT use any PHP Soap libraries as the intention is to show from scratchhow to build and send the HTTP request. Additionally the article shows how to parse XML responses and how to use XPath. The samples are based on a reusable webservice client class. The intention of the code is to show the basics of webservices. Complex topics like WSDL are not covered. If you never used PHP, you will find a beginner tutorial at the end of the article on how to install and run the samples on Windows. After reading this article and studying the samples, you will notice that there is no webservice which equals another one. They ALL have their own individual characteristics.
Sky: Partly Cloudy Temperature: 18C Feels Like: 18C Dew Point: 13C Pressure: 1010.8 mb Humidity: 73% Visibility: 10.0 km Wind Speed: 21 km/h Wind Direction: WSW UV Index: 2
The server calculates the result and returns it as XML. The data is sent via POST. Request: Operation = Multiply Value1 = 21 Value2 =3 Response: Result = 63
Subscription
For those webservices which require subscription, you can find the links and more information in the source code comments.
Elm