I tried to declare function as normal function too,but didn't solved my problem. I was able to run the server code with single function as found in many tutorials but cannot add multiple function. plz suggest me how can i do that.
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Support extends CI_Controller {
public $ns="";
function __construct()
{
parent::__construct();
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$this->load->library("nusoap_library");
$this->load->model('support_model');
$this->nusoap_server = new soap_server();
$this->ns = 'http://'.$_SERVER['HTTP_HOST'].'/index.php/soapserver/';
//$ns ="urn:server";
$this->nusoap_server->configureWSDL("SupportWsdl", $this->ns); // wsdl cinfiguration
$this->nusoap_server->wsdl->schemaTargetNamespace = $this->ns; // server namespace
//first simple function
$this->nusoap_server->register('hello',
array('username' => 'xsd:string'), //parameter
array('return' => 'xsd:string'), //output
'urn:server', //namespace
'urn:'.$this->ns.'helloServer', //soapaction
'rpc', // style
'encoded', // use
'Just say hello'); //description
//this is the second webservice entry point/function
$this->nusoap_server->register('login',
array('username' => 'xsd:string', 'password'=>'xsd:string'), //parameters
array('return' => 'tns:Person'), //output
'urn:server', //namespace
'urn:'.$this->ns.'loginServer', //soapaction
'rpc', // style
'encoded', // use
'Check user login'); //description
//first function implementation
function hello() {
function hello($username){
$this->nusoap_server->service($HTTP_RAW_POST_DATA);
return 'Howdy, '.$username.'!';
}
}
//second function implementation
function login($username, $password) {
//should do some database query here
//just some dummy result
return array(
'id_user'=>1,
'fullname'=>'John Reese',
'email'=>'john@reese.com',
'level'=>99
);
// $this->nusoap_server->service($HTTP_RAW_POST_DATA);
}
}
function index()
{
$this->nusoap_server->service(file_get_contents("php://input"));// read raw data from request body
}
}