Creating Web-Services Apache 2.2 server

 

boxing.wsdl

<?xml version="1.0" ?>
<definitions name="boxing"
targetNamespace="http://manas10/myphp/webservices/ex2/"
xmlns:tns="http://manas10/myphp/webservices/ex2/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<message name="getQuoteRequest">
<part name="boxer" type="xsd:string" />
</message>
<message name="getQuoteResponse">
<part name="return" type="xsd:string" />
</message>
<portType name="QuotePortType">
<operation name="getQuote">
<input message="tns:getQuoteRequest" />
<output message="tns:getQuoteResponse" />
</operation>
</portType>
<binding name="QuoteBinding" type="tns:QuotePortType">
<soap:binding
style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
<operation name="getQuote">
<soap:operation soapAction="" />
<input>
<soap:body use="encoded"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
<output>
<soap:body use="encoded"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</output>
</operation>
</binding>
<service name="boxing">
<documentation>Returns quote from famous pugilists</documentation>
<port name="QuotePort" binding="tns:QuoteBinding">
<soap:address
location="http://manas10/myphp/webservices/ex2/boxingserver.php" />
</port>
</service>
</definitions>

boxingserver.php

<?php
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,
there's just a whole lot more smoke. (1995)";
} else {
$quote = "Sorry, $boxer was not found.";
}
return $quote;
}
}
$soapserver = new SoapServer("boxing.wsdl");
$soapserver->setClass("boxingQuotes");
$soapserver->handle();
?>
 

boxing_client.php

<?php
$client = new SoapClient("boxing.wsdl");
echo $client->getQuote("Ali");
echo("<br/>");
echo $client->getQuote("Foreman");
?>