Jump to Navigation

071 - SOAP Client and Server Interaction

This SOAP service retrieves a famous quote from a particular boxer, and that boxer's last name is requested using the exposed
getQuote() method. It's based on the boxing.wsdl file.

Creating the Boxing Server :

The boxing server is simple but practical. Extending this to this connect to database server would be a trivial affair.


class boxingQuotes {

function getQuote($boxer) {

if ($boxer == "Tyson") {

$quote = "My main objective is to be professional but to kill him. (2002)";

} elseif ($boxer == "Ali") {

$quote = "I am the greatest. (1962)";

} elseif ($boxer == "Foreman") {

$quote = "Generally when there's a lot of smoke. (1995)";

} else {

$quote = "Sorry, $boxer was not found.";


return $quote;



$soapserver = new SoapServer("boxing.wsdl");


Executing the Boxing Client:

The boxing client consists of just two lines, the first instantiating the WSDL-enabled SoapClient() class, and the second executing the exposed method
getQuote(), passing in the parameter "Ali".


$client = new SoapClient("boxing.wsdl");

echo $client->getQuote("Ali");


Executing the client produces the following output:

I am the greatest. (1962)

Main menu 2

Story | by Dr. Radut