日期:2014-05-20 浏览次数:20621 次
<?php
$soap = new SoapServer(null,array('uri'=>"http://www.test.com/"));
$soap->addFunction('minus_func');
$soap->addFunction('hello');
$soap->addFunction(SOAP_FUNCTIONS_ALL);
$soap->handle();
function minus_func($i, $j)
{
$res = $i - $j;
return $res;
}
function hello()
{
$date=array(
get_response=>array(
'user'=>'zhangsan',
'pass'=>'123456',
'msg'=>'user and pass is right',
'code'=>'10'
)
);
return json_encode($date);
}
?>
<?php
try {
$client = new SoapClient(null,
array(
'location' =>"http://www.test.com/webservice.php",
'uri' => "http://192.168.1.102/"
)
);
// echo $client->minus_func(34,30);
echo $client->hello();
} catch (SoapFault $fault){
echo "Error: ",$fault->faultcode,", string: ",$fault->faultstring;
}
?>