在CakePHP中使用NuSOAP实现Web服务

时间:2013-09-11 12:26:55

标签: php web-services cakephp cakephp-2.0 nusoap

我编写的代码如下所示:

App::uses('AppController', 'Controller');
App::uses('CakeTime', 'Utility');
App::import('Vendor', 'Nusoap', array('file' => 'Nusoap' . DS . 'lib' . DS . 'nusoap.php'));

class ApiController extends AppController {

    /**
     * Controller name
     *
     * @var string
     */
    public $name = 'Api';
    public $uses = array();

    function index() {
        $server = new soap_server();
        $server->configureWSDL("Testing WSDL ", "urn:Testing WSDL ", "http://localhost/test/api");

        $server->register("gethelloworld", array("name" => "xsd:string"), array("return" => "xsd:string"), "urn:helloworld", "urn:helloworld#gethelloworld");

        function gethelloworld($name) {
            $myname = "My Name Is <b>" . $name . "</b>";
            return $myname;
        }

        $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
        $server->service($HTTP_RAW_POST_DATA);
    }

}

但每当我运行它时,我都会收到以下通知:

Notice (8): Undefined index: _transient [APP\Vendor\Nusoap\lib\nusoap.php, line 226]

我在这里遗漏了什么吗?以下是我致电http://localhost/test/api

时的屏幕截图

screenshot

1 个答案:

答案 0 :(得分:0)

仔细检查您的文件和配置。使用您的设置(我正在使用CakePHP v2.4.0)我没有问题:

enter image description here