Web Service howto
A web service can be thought of as a software component, that resides in the server, which is accessed over a network, in a a platform independent manner.
The example described below ouputs a list of prime numbers. The client is written in php and it prints the result and all the SOAP headers. As from the fugure Service Consumer refers to the client machine, Service producer refers to the server providing the service and Registry is www.xmethods.net. We get information about the web service from the UDDI aka xmethods.net. WSDL published there provides a standard way of defining the services provided in a programming language/platform independent manner.
xmethods page: http://www.xmethods.net/ve2/ViewListing.po;jsessionid=tBae8rKD0d-ckrQBEYVCSe1E?key=427565
Working
This needs php5-cli and php-soap. These packages can be installed from net by running the following command in terminal
debian:/var/www# sudo apt-get install php5-cli php-soap
After installing this the code can be executed by running the following command in terminal
debian:/var/www# php prime.php
==================================================================
The Prime numbers less than or equal to 50 are 1,3,5,7,11,13,17,19,23,29,31,37,41,43,47
==================================================================
SOAP request headers:
POST /vbfacileinpt/np.asmx HTTP/1.1
Host: www50.brinkster.com
Connection: Keep-Alive
User-Agent: PHP-SOAP/5.2.6-1+lenny9
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://microsoft.com/webservices/GetPrimeNumbers"
Content-Length: 279
SOAPrequest:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://microsoft.com/webservices/"><SOAP-ENV:
Body><ns1:GetPrimeNumbers><ns1:max>50</ns1:max></ns1:GetPrimeNumbers></SOAP-ENV:Body></SOAP-ENV:Envelope>
SOAP response headers:
HTTP/1.1 200 OK
Date: Thu, 25 Nov 2010 09:00:22 GMT
Server: Microsoft-IIS/6.0
Set-Cookie:
X-Powered-By: ASP.NET
X-AspNet-Version: 1.1.4322
Cache-Control: private, max-age=0
Content-Type: text/xml; charset=utf-8
Content-Length: 426
SOAP response:
<?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><GetPrimeNumbersResponse xmlns="http://microsoft.com/webservices/"><GetPrimeNumbersResult>1,3,5,7,11,13,17,19,23,29,31,37,41,43,47</GetPrimeNumbersResult></GetPrimeNumbersResponse></soap:Body></soap:Envelope>