#1 chinakr

基于SpeedPHP 3.1.89。

controller/admin.php源代码:

class admin extends spController
{
    function soap_extension() {
        $uri = 'http://www.htexam.net/api/ws_24hnews.php?wsdl';
        $client = new SoapClient($uri);    // WSDL模式
        $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: ';
        var_dump($result);    // string(1517804) "[{"Title":"20115e748d355dde7701516d76d86c345e025e0276f44e8b4e1a535562df805875284eba5458540d5355","Content":"...","Updatetime":"1324607604","TypeName":"80038bd552a86001"},...]"
    }
}
?>

访问方式:
http://localhost/index.php?c=admin&a=soap_extension

来源:chinakr的博客,http://blog.quickbest.net/archives/php/php-soapclient-wsdl-sample.html

该贴已经同步到 chinakr的微博

2011-12-23 13:12:15