Welcome Guest, Not a member yet? Register   Sign In
Problem with CI and Nusoap
#1

[eluser]gao[/eluser]
Hello everybody! I'm trying to implement nusoap with CI using CI Nusoap Library. I've wrote this server:

Code:
<?php
class TestController extends Controller
{
    
    function TestController()
    {
        parent::Controller();
        $controllerName = "TestController";
        $this->load->library('NusoapLib');
        $this->nusoap_server = new soap_server();
        $this->nusoap_server->configureWSDL($controllerName, "urn:$controllerName", base_url().'admin/'.strtolower($controllerName));
        $this->nusoap_server->xml_encoding = 'UTF-8';
        $this->controllerName = $controllerName;
        
        $this->nusoap_server->register("hello",
            array("name" => "xsd:string"),
            array("return"=>"xsd:string"),
            "urn:TestController",
            "urn:TestController#hello",
            "rpc",
            "encoded",
            "Say hello world");
    }

    function index()
    {
        if($this->uri->rsegment(2) == "wsdl") {
            $_SERVER['QUERY_STRING'] = "wsdl";
        } else {
            $_SERVER['QUERY_STRING'] = "";
        }
        
            $this->nusoap_server->service(file_get_contents("php://input"));
            die();
    }
    
    function wsdl() {
        $this->index();
    }
    
    function hello($name) {
        return "Hello $name";
    }

}
?>

And I also have this client:

Code:
<?php
class Test2Controller extends Controller{
    
    function Test2Controller() {
        parent::Controller();
        $this->load->library('NusoapLib');
    }
    
    function index() {
        $this->nusoap_client = new nusoap_client("http://localhost/roda/quieromesa/admin/testcontroller/wsdl", 'wsdl');
        $this->nusoap_client->xml_encoding = 'UTF-8';
        $result = $this->nusoap_client->call(
            'hello',
            array('name' => 'Leandro')
        );
        
        echo '<strong>Request:</strong> <xmp>' . $this->nusoap_client->request . '</xmp>';
        echo '<strong>Response:</strong> <xmp>' . $this->nusoap_client->response . '</xmp>';
        echo '<strong>Debug log:</strong> <pre>' . $this->nusoap_client->debug_str . '</pre>';
        die();
        if($this->nusoap_client->fault)
        {
            $this->output->set_output('Error 1: '.$this->nusoap_client->faultcode);
        } else if ($this->nusoap_client->getError()) {
            $this->output->set_output('Error 2: '.$this->nusoap_client->getError());
        } else {
            $this->output->set_output('Message: ' . $result);
        }
    }
}
?&gt;

When I try to test the nusoap I get this message with a 500 error: method 'hello' not defined in service

Anybody could tell me what's happening?

Regards!




Theme © iAndrew 2016 - Forum software by © MyBB