Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter and SOAP Server (context of $this object)
#1

[eluser]stevefink[/eluser]
Hi all,

I'm trying to build my SOAP abstraction layer into an existing CI application. I'm having a bit of a problem with scope in this case. When I try to access my dbmodel, which would normally be done with something such as: $this->dbmodel->method(), it cannot find the Dbmodel object. A code snippet looks like the following:

Code:
class Soap extends Controller {
    
    function Soap()
    {
        parent::Controller();
        $this->load->model('Dbmodel', 'dbmodel');
        
        // SOAP server handlers initialized here.
        $server = new SoapServer("mywsdl.wsdl");
        $server->setObject($this);
        $server->handle();
        exit;  // This is required, otherwise CI sends additional headers to the client breaking everything in the way.  Still can't find where in CI these headers originate from, but that's a different problem.
    }                    
    
    function foo($stuff)
    {  
        
        $pretty = $this->dbmodel->please_do_stuff($sid);
    
    }    

}

When foo() is executed, I get something such as the following:

Call to undefined method Dbmodel::please_do_stuff()

I'm under the impression that I'm within the context of the Soap class, and not the controller instance. Would be curious as to how to switch the context so I can properly access the database.

Anyone have similar woes?

Thanks!
#2

[eluser]Seppo[/eluser]
Judging by the error message, $this->dbmodel is having a Dbmodel object as it should... Does Dbmodel has the please_do_stuff method?
It seems like a stupid question, but the object is an instance of the expected class, so that is the only thing I can think that can fail
#3

[eluser]Unknown[/eluser]
[quote author="stevefink" date="1214806178"]Hi all,

I'm trying to build my SOAP abstraction layer into an existing CI application. I'm having a bit of a problem with scope in this case. When I try to access my dbmodel, which would normally be done with something such as: $this->dbmodel->method(), it cannot find the Dbmodel object. A code snippet looks like the following:

Code:
class Soap extends Controller {
    
    function Soap()
    {
        parent::Controller();
        $this->load->model('Dbmodel', 'dbmodel');
        
        // SOAP server handlers initialized here.
        $server = new SoapServer("mywsdl.wsdl");
        $server->setObject($this);
        $server->handle();
        exit;  // This is required, otherwise CI sends additional headers to the client breaking everything in the way.  Still can't find where in CI these headers originate from, but that's a different problem.
    }                    
    
    function foo($stuff)
    {  
        
        $pretty = $this->dbmodel->please_do_stuff($sid);
    
    }    

}

When foo() is executed, I get something such as the following:

Call to undefined method Dbmodel::please_do_stuff()

I'm under the impression that I'm within the context of the Soap class, and not the controller instance. Would be curious as to how to switch the context so I can properly access the database.

Anyone have similar woes?

Thanks![/quote]

Hi:

I'm a new Soap developer, I'm trying to develop a Web Services with CI, but I don't know how define the <soap:address location="..."/> on the WSDL file.




Theme © iAndrew 2016 - Forum software by © MyBB