带CakePHP的NuSoap,错误为黑色孔
我正在尝试使用cakePHP和nusoap创建一个webservices,当我在cakePHP之外测试这段代码时,这段代码可以正常工作,但在cakePHP内部我有一个错误: 错误日志带CakePHP的NuSoap,错误为黑色孔,php,cakephp,nusoap,Php,Cakephp,Nusoap,我正在尝试使用cakePHP和nusoap创建一个webservices,当我在cakePHP之外测试这段代码时,这段代码可以正常工作,但在cakePHP内部我有一个错误: 错误日志 2015-04-17 14:24:32 Error: [BadRequestException] The request has been black-holed Request URL: /epedidos/Soap/?wsdl= Stack Trace: #0 C:\xampp\htdocs\epedidos\
2015-04-17 14:24:32 Error: [BadRequestException] The request has been black-holed
Request URL: /epedidos/Soap/?wsdl=
Stack Trace:
#0 C:\xampp\htdocs\epedidos\lib\Cake\Controller\Component\SecurityComponent.php(239): SecurityComponent->blackHole(Object(SoapController), 'auth')
#1 [internal function]: SecurityComponent->startup(Object(SoapController))
#2 C:\xampp\htdocs\epedidos\lib\Cake\Utility\ObjectCollection.php(128): call_user_func_array(Array, Array)
#3 [internal function]: ObjectCollection->trigger(Object(CakeEvent))
#4 C:\xampp\htdocs\epedidos\lib\Cake\Event\CakeEventManager.php(242): call_user_func(Array, Object(CakeEvent))
#5 C:\xampp\htdocs\epedidos\lib\Cake\Controller\Controller.php(675): CakeEventManager->dispatch(Object(CakeEvent))
#6 C:\xampp\htdocs\epedidos\lib\Cake\Routing\Dispatcher.php(187): Controller->startupProcess()
#7 C:\xampp\htdocs\epedidos\lib\Cake\Routing\Dispatcher.php(165): Dispatcher->_invoke(Object(SoapController), Object(CakeRequest))
#8 C:\xampp\htdocs\epedidos\app\webroot\index.php(108): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))
#9 {main}
这出现在我的屏幕上(从cakephp中测试web服务功能)
这是我的控制器:
App::uses('HttpSocket', 'Network/Http');
App::import('Vendor','soap/lib/nusoap');
class SoapController extends AppController {
public $components = array('Security', 'RequestHandler');
public $useTable = false;
public function index() {
$this->autoRender = false;
$this->layout = false;
function doAuthenticate() {
if (isset($_SERVER['PHP_AUTH_USER']) and isset($_SERVER['PHP_AUTH_PW'])) {
if ($_SERVER['PHP_AUTH_USER'] == "admin" && $_SERVER['PHP_AUTH_PW'] == "admin")
return true;
else
return false;
}
}
function hello($name) {
if (!doAuthenticate())
return "Invalid username or password";
$myname = "<br/> Well done, <b>" . $name . "</b>, your web services work!";
return $myname;
}
$server = new soap_server();
$server->configureWSDL("epedidos","urn:epedidos", "http://localhost/epedidos/Soap/?wsdl");
$server->register("hello",
array("name" => "xsd:string"),
array("return" => "xsd:string"),
"urn:epedidos",
"urn:epedidos#hello",
"rpc",
"encoded",
"hello manolo"
);
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);
}
public function beforeFilter(){
parent::beforeFilter();
$this->Auth->Allow('index');
}
}
App::使用('HttpSocket','Network/Http');
应用程序::导入('Vendor','soap/lib/nusoap');
类SoapController扩展了AppController{
public$components=array('Security','RequestHandler');
public$useTable=false;
公共职能指数(){
$this->autoRender=false;
$this->layout=false;
函数doAuthenticate(){
如果(isset($_服务器['PHP\u AUTH\u用户'])和isset($_服务器['PHP\u AUTH\u PW'])){
如果($\u服务器['PHP\u AUTH\u USER']==“admin”&&$\u服务器['PHP\u AUTH\u PW']==“admin”)
返回true;
其他的
返回false;
}
}
函数hello($name){
如果(!doAuthenticate())
返回“无效用户名或密码”;
$myname=“
做得好,“.$name.”,您的web服务工作正常;
返回$myname;
}
$server=新的soap_服务器();
$server->configureWSDL(“epedidos”,“urn:epedidos”http://localhost/epedidos/Soap/?wsdl");
$server->register(“你好”,
数组(“名称”=>“xsd:string”),
数组(“return”=>“xsd:string”),
“urn:epedidos”,
“urn:epedidos#你好”,
“rpc”,
“编码”,
“你好,马诺洛”
);
$HTTP_RAW_POST_DATA=isset($HTTP_RAW_POST_DATA)?$HTTP_RAW_POST_DATA:“”;
$server->service($HTTP\u RAW\u POST\u数据);
}
公共函数beforeFilter(){
父::beforeFilter();
$this->Auth->Allow('index');
}
}
当我访问的url不显示正常的XML时,显示描述“hello manolo”和2个字段
我的客户端是index.php
require_once("lib/nusoap.php");
//Create web service client
//$client = new nusoap_client("http://localhost/ws/ws-servidor.php?wsdl", true);
$client = new nusoap_client("http://localhost/epedidos/Soap/?wsdl", 'wsdl');
$client->setCredentials("admin", "admin", "basic");
echo $client->call('hello', array('name' => 'teste'));
if($client->getError()){
echo '<p>Error on contructor <pre>' . print_r($client->getError()) . '</pre></p>';
}
unset($client);
require_once(“lib/nusoap.php”);
//创建web服务客户端
//$client=新的nusoap_客户端(“http://localhost/ws/ws-servidor.php?wsdl“,对);
$client=新的nusoap_客户端(“http://localhost/epedidos/Soap/?wsdl“,‘wsdl’”;
$client->setCredentials(“admin”、“admin”、“basic”);
echo$client->call('hello',array('name'=>'teste');
如果($client->getError()){
在构造函数上回显“错误”。打印($client->getError())。”;
}
未结算($客户);
如果我做错了什么,请告诉我如何解决这个问题
谢谢
require_once("lib/nusoap.php");
//Create web service client
//$client = new nusoap_client("http://localhost/ws/ws-servidor.php?wsdl", true);
$client = new nusoap_client("http://localhost/epedidos/Soap/?wsdl", 'wsdl');
$client->setCredentials("admin", "admin", "basic");
echo $client->call('hello', array('name' => 'teste'));
if($client->getError()){
echo '<p>Error on contructor <pre>' . print_r($client->getError()) . '</pre></p>';
}
unset($client);