服务端代码:
class ContactsserverController extends HproseController{
protected $crossDomain = true;
protected $P3P = true;
protected $get = true;
protected $debug = true;
public function test1(){
return 'test1';
}
public function test2(){
return 'test2';
}
}
客户端调用代码:
public function index(){
vendor('Hprose.HproseHttpClient');
$client = new \HproseHttpClient('http://192.168.1.117/interface.php/contactsserver');
dump($client);
// 或者采用 //$client = new \HproseHttpClient();
//$client->useService('http://serverName/index.php/Home/Server');
$result = $client->test1();
print_r($result);
}
调用我本地起来的Hprose 服务:
http://local.tyq.com/interface.php/contactsserver
可以 返回
本地调用测试服务器的地址:
http://192.168.1.117/interface.php/contactsserver
返回错误:
:(
Tag 'RAEz' expected, but '
错误位置
FILE: E:\pengbei\tyq\Croe\Library\Vendor\Hprose\HproseReader.php LINE: 272
TRACE
#0 E:\pengbei\tyq\Croe\Library\Vendor\Hprose\HproseClient.php(73): HproseSimpleReader->checkTags(Array)
#1 E:\pengbei\tyq\Croe\Library\Vendor\Hprose\HproseClient.php(112): HproseClient->invoke('test1', Array)
#2 E:\pengbei\tyq\App\Home\Controller\IndexController.class.php(162): HproseClient->__call('test1', Array)
#3 E:\pengbei\tyq\App\Home\Controller\IndexController.class.php(162): HproseHttpClient->test1()
#4 [internal function]: Home\Controller\IndexController->index()
#5 E:\pengbei\tyq\Croe\Library\Think\App.class.php(162): ReflectionMethod->invoke(ob
#6 E:\pengbei\tyq\Croe\Library\Think\App.class.php(200): Think\App::exec()
#7 E:\pengbei\tyq\Croe\Library\Think\Think.class.php(120): Think\App::run()
#8 E:\pengbei\tyq\Croe\index.php(96): Think\Think::start()
#9 E:\pengbei\tyq\index.php(19): require('E:\pengbei\tyq\...')
#10 {main}
ThinkPHP3.2.2 { Fast & Simple OOP PHP fr
最佳答案