服务器端[提供者]:
$soap = new SoapServer(null,array('uri'=>"http://221.10.28.228:8081/soap/"));//This uri is your SERVER ip.
$soap->addFunction('minus_func'); //Register the function
$soap->addFunction(SOAP_FUNCTIONS_ALL);
$soap->handle();
function minus_func($str){
return $res = 'Hello world!'.$str;
}
客户端[使用者]:
try {
$client = new SoapClient(null,
array('location' =>"http://221.10.28.228:8081/soap/s.php",'uri' => "http://221.10.28.228:8081/soap")
);
echo $client->minus_func('you are so great');
} catch (SoapFault $fault){
echo "Error: ",$fault->faultcode,", string: ",$fault->faultstring;
}
运行结果: