#1 chinakr
基于SpeedPHP 3.1.89。controller/admin.php文件源代码:
class admin extends spController
{
function soap_client() {
$uri = 'http://www.5haoxue.net/';
$location = 'http://localhost/5haoxue/index.php?c=admin&a=soap_server';
$client = new SoapClient(NULL, array('location' => $location, 'uri' => $uri));
$soap_func_list = $client->__getFunctions();
echo 'SOAP functions: ';
var_dump($soap_func_list); // 对于非WSDL模式的SOAP,返回值是NULL?
echo '
';
$soap_type_list = $client->__getTypes();
echo 'SOAP types: ';
var_dump($soap_type_list); // 对于非WSDL模式的SOAP,返回值是NULL?
echo '
';
$result = $client->__soapCall('hello', array()); // 函数名不区分大小写
echo 'Hello function call: ';
var_dump($result);
}
function soap_server() {
function hello() {
return 'Hello, kind SOAP user!';
}
$server = new SoapServer(NULL, array('uri' => 'http://www.5haoxue.net/'));
$server->addFunction('hello');
$server->handle();
}
}
?>
访问
http://localhost/5haoxue/index.php?c=admin&a=soap_server
结果为空。
访问
http://localhost/5haoxue/index.php?c=admin&a=soap_client
结果为:
SOAP functions: NULL
SOAP types: NULL
Hello function call: string(22) "Hello, kind SOAP user!"
结果截图参考“非WSDL模式的SoapServer和SoapClient使用实例截图_2011-12-23.png”。
来源:chinakr的博客,http://blog.quickbest.net/archives/php/non-wsdl-php-soapserver-soapclient-sample.html
该贴已经同步到 chinakr的微博
2011-12-23 13:15:10