Welcome Guest, Not a member yet? Register   Sign In
SOAP server in controller
#1

[eluser]steelaz[/eluser]
Right now I have this controller:

Code:
class Soap extends Controller
{
    public function __construct()
    {
        parent::__construct();
    }

    public function server()
    {    
        include_once(APPPATH . 'soap/qb_server.php');

        $wsdl = $this->config->item('qb_wsdl_uri');

        ini_set("soap.wsdl_cache_enabled", "0");
        $server = new SoapServer($wsdl);
        $server->setClass('qb_server');
        $server->handle();
    }
}

As you can see, I'm loading /application/soap/qb_server.php and it handles SOAP requests. Everything works fine, but I would prefer to have SOAP functions as private methods in controller itself, I tried using $server->addFunction('function_name') instead of $server->setClass('qb_server'), but I understand it looks for functions in global scope?
#2

[eluser]gon[/eluser]
This probably should be asked in the library forum (if there is any...)

Anyway, maybe the addFunction method works the same way as call_user_func from native PHP, where you can pass the name of a global function, or an array containing an object and a method name.

See the example #4 here:

http://www.php.net/call_user_func
#3

[eluser]steelaz[/eluser]
Thanks gon, but addFunction() only accepts string. Instead I changed setClass() to the name of my controller - $server->setClass('Soap') and it worked.
#4

[eluser]abbasmn[/eluser]
we had this issue, here how we fixed it:
Code:
class Ws_server extends Controller
{
    private $test;
    function  __construct()
        {
            
        }
    function my_server()
    {        
        try
        {
    
        ini_set("soap.wsdl_cache_enabled", "0");
           $server = new SoapServer("http://localhost/Hello.wsdl",
          array('soap_version' => SOAP_1_2));
           $server->setClass("Ws_server");
           $server->handle();
                      
            }
        catch (SoapFault $exception)    
        {
                echo $exception;      
          }
    }
    
    public function hello($someone)
        {
        //this function is called by client and is in Hello.wsdl
        return "Hello".$someone." My QUEUE:".$this-> my_q();
        
        }

    private function my_q()
    {
        parent::Controller();
           $this->load->model('search_model','');
           $this->test= $this->search_model->get_queue();    
           return $this->test;
    }
            
}




Theme © iAndrew 2016 - Forum software by © MyBB