CakePHP 3肥皂服务器错误

时间:2016-11-16 13:22:51

标签: php cakephp cakephp-3.0

我尝试在CakePHP 3中创建一个Soap服务器,但如果我想连接我的客户端,我每次都会出错。

我在一个函数中设置服务器:

public function view($id) {

    $connection = ConnectionManager::get('default');
    $user = $connection->execute('SELECT * FROM users WHERE id='.'"'.$id.'"')->fetchAll('assoc');

    $obj = new Post;

    $this->viewBuilder()->layout = false;
    $this->autoRender = false;
    ini_set("soap.wsdl_cache_enabled",0); //disable wsdl cache

    $server = new SoapServer(null, array(
        'uri' => 'http://localhost/test-uri',
        'encoding'=>'UTF-8'
    )
    );

    $server->setObject($obj);
    $server->handle();  

}

在模型中我创建了这个函数:

namespace App\Model\Entity;

use Cake\ORM\Entity;
use Cake\Utility\Xml;

class Post {

    function testfunktion($param){

        return $param;

    }

}

我的客户端脚本显示:

$soap = new SoapClient( 
null, 
array( 
   "location" => "http://localhost/shop_system/users/view/2",
   "uri" => "http://test-uri",
   "trace" => 1
  ) 
);

try {
    $product = $soap->testfunktion("Michael");
} catch (SoapFault $e) {
    echo $e;
    print($soap->__getLastResponse());
}

这是我的输出:

  

SoapFault异常:[Client]看起来我们在C:\ xampp \ htdocs \ shop_system \ webroot \ client.php中没有XML文档:15堆栈跟踪:#0 C:\ xampp \ htdocs \ shop_system \ webroot \ client .php(15):SoapClient-> __ call('testfunktion',Array)#1 C:\ xampp \ htdocs \ shop_system \ webroot \ client.php(15):SoapClient-> testfunktion('Michael')#2 {主要}   注意(8):未定义的索引:HTTP_ACCEPT_LANGUAGE [APP / Controller \ UsersController.php,第22行] Michael

我不知道这个错误我必须做什么

0 个答案:

没有答案