#1 chinakr
基于SpeedPHP 3.1.89。controller/admin.php文件源代码:
class admin extends spController
{
function soap_client_wsdl() {
/* WSDL模式的SoapClient */
$uri = 'http://www.htexam.com/api/24hnews.php?wsdl';
//$uri = 'http://localhost/5haoxue/index.php?c=admin&a=soap_server_wsdl';
$client = new SoapClient($uri);
$soap_func_list = $client->__getFunctions();
echo 'SOAP functions: ';
var_dump($soap_func_list); // array(1) { [0]=> string(14) "string Hello()" }
echo '
';
$soap_type_list = $client->__getTypes();
echo 'SOAP types: ';
var_dump($soap_type_list);
echo '
';
$result = $client->__soapCall('Hello', array());
echo 'Hello function call: ';
$result = json_decode($result, TRUE);
//var_dump($result); // 中文变成乱码,var_dump()不支持中文!
dump($result); // 中文正常显示
}
}
访问方式:
http://localhost/index.php?c=admin&a=soap_client_wsdl
来源:chinakr的博客,http://blog.quickbest.net/archives/php/php-json_decode-sample.html
该贴已经同步到 chinakr的微博
2011-12-23 15:16:49