policy2.wsdl
Code:
<?xml version='1.0' encoding='UTF-8'?>
<definitions name='policy2'
targetNamespace="http://localhost/test2/policy2.wsdl"
xmlns:tns="http://localhost/test2/policy2.wsdl"
xmlns:soap-env="http://www.w3.org/2003/05/soap-envelope"
xmlns:soap-enc="http://www.w3.org/2003/05/soap-encoding"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsd1='http://localhost/test2/policy.xsd'
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:WSDL="http://schemas.xmlsoap.org/wsdl/"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<message name='getQuote'>
<part name='symbol' type='xs:string'/>
</message>
<message name='getQuoteResponse'>
<part name='return' type='xs:float'/>
</message>
<portType name='policyPortType'>
<operation name='getQuote'>
<input message='tns:getQuote'/>
<output message='tns:getQuoteResponse'/>
</operation>
</portType>
<binding name="policySoap" type="tns:policyPortType">
<soap:binding style='rpc' transport='http://schemas.xmlsoap.org/soap/http'/>
</binding>
<service name='policyService'>
<port name='policyPort' binding='tns:policySoap'>
<soap:address location='http://localhost/test2/server2.php'/>
</port>
</service>
</definitions>
client4.php
Code:
<?php
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$ini = ini_set("soap.wsdl_cache_enabled","0");
$client = new SoapClient("http://localhost/test2/policy2.wsdl");
try {
echo "<pre>\n";
print($client->getQuote("ibm"));
echo "\n";
print($client->getQuote("microsoft"));
echo "\n</pre>\n";
} catch (SoapFault $exception) {
echo $exception;
}
?>
server2.php
Code:
<?php
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
class QuoteService {
private $quotes = array("ibm" => 98.44, "microsoft" => 101.34);
function getQuote($symbol) {
if (isset($this->quotes[$symbol])) {
return $this->quotes[$symbol];
} else {
throw new SoapFault("Server","Unknown Symbol '$symbol'.");
}
}
}
$server = new SoapServer("policy2.wsdl");
$server->setClass("QuoteService");
$server->handle();
?>
upon accessing client4.php:
not a valid method.