0

I'm new to Codeigniter and SOAP web services. I'm getting Error response to my below.

<?php
class Webservice extends CI_Controller {

    var $ns = "http://localhost/website/webservice";

    public function __construct()
    {
        parent::__construct();
        $this->load->library("Nusoap_lib");

        $this->server = new soap_server();
        // Initialize WSDL support
        $this->server->configureWSDL('hellowsdl', 'urn:hellowsdl');
        // Register the method to expose
        $this->server->register('hello');


        // Define the method as a PHP function
    }

    public function hello() {
        return 'Hello, ';
    }

    function index()
    {
        $this->server->service($this->ns);
    }
?>

Please anybody help me what is the problem in my code. Thanks.

1 Answers1

0

Declare hello function inside index() function it worked for me. but declaring out of index() function gave me problem.

<?php
class Webservice extends CI_Controller {

var $ns = "http://localhost/website/webservice";

public function __construct()
{
    parent::__construct();
    $this->load->library("Nusoap_lib");

    $this->server = new soap_server();
    // Initialize WSDL support
    $this->server->configureWSDL('hellowsdl', 'urn:hellowsdl');
    // Register the method to expose
    $this->server->register('hello');


    // Define the method as a PHP function
}

function index()
{
    $this->server->service($this->ns);
        public function hello() {
    return 'Hello, ';
}

}
 ?>
Dipen
  • 1,056
  • 1
  • 19
  • 36