PHP自速soap实例

来源:互联网 发布:linux中的tar命令 编辑:程序博客网 时间:2024/05/16 01:04

服务器端[提供者]:

$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;}

运行结果: