dsvjw20866 2015-04-17 12:35
浏览 35

NuSoap与CakePHP,错误黑洞

I am trying to create a webservices using cakePHP and nusoap, when I test this code outside of cakePHP this code works done, but inside of cakephp I have a error black-holed:

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}

and this is appears in my screen(out of cakephp to test web services function)

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

1

It is my Controller:

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

}

When I access the url http://localhost/epedidos/Soap/?wsdl doesn't show a normal XML, show the description "hello manolo" and 2 fields

enter image description here

My client is 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);

Please tell me if I am doing a something wrong and how to solve this problem,

Thanks.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 ogg dd trandata 报错
    • ¥15 高缺失率数据如何选择填充方式
    • ¥50 potsgresql15备份问题
    • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
    • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
    • ¥60 pb数据库修改与连接
    • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
    • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
    • ¥20 神经网络Sequential name=sequential, built=False
    • ¥16 Qphython 用xlrd读取excel报错