NuSoap与CakePHP,错误黑洞

时间:2015-04-17 12:35:32

标签: php cakephp nusoap

我正在尝试使用cakePHP和nusoap创建一个web服务,当我在cakePHP之外测试这段代码时,这段代码完成了,但是在cakephp里面我有一个黑洞错误:

error.log中

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}

这出现在我的屏幕上(用于测试Web服务功能的cakephp)

HTTP Error: Unsupported HTTP response status 400 Bad Request (soapclient->response has contents of the response)
Error on contructor

1

这是我的控制器:

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');
    }

}

当我访问网址时,http://localhost/epedidos/Soap/?wsdl未显示正常的XML,请显示描述“hello manolo”和2个字段

enter image description here

我的客户是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);

请告诉我,如果我做错了什么以及如何解决这个问题,

感谢。

0 个答案:

没有答案