rowiebiz Posted December 31, 2010 Share Posted December 31, 2010 Hi, I have a code below and I keep on getting the error "Fatal error: Call to a member function call() on a non-object in on line 29". Can someone help me please to fix and solve the error. Please help. The line 29 here is the section that say $this->apiresult = $this->apiclient->call($apimethodname); but I think I already instantiated the $this->apiclient via the constructor Please Help. <?php // includes nusoap class require_once('lib/nusoap.php'); class dashcs { public $apiresult = null; public $apierror = null; public $apiclient = ''; function __constuct(&$apiclient) { // instantiate the web service api $this->apiclient = $apiclient; $this->apiclient->setCredentials("rrusdf","959dfde3","basic"); $this->apierror = $this->apiclient->getError(); if($this->apierror) { return false; }else{ return true; } } // function dashCallMethod($apimethodname = null,$apiparameters= null) { // call the method of the service if($apiparameters == null || $apiparameters == ''){ $this->apiresult = $this->apiclient->call($apimethodname); }else{ $this->apiresult = $this->apiclient->call($apimethodname,$apiparameters); } if($this->apiclient->fault){ // check for fault return false; }else{ // Check for errors $this->apierror = $this->apiclient->getError(); if ($this->apierror) { return false; }else{ return true; } } } } // Create objects $apiclient = new nusoap_client('https://service.dsdff.com/dash-api/soap/emergencyprovisioning/v1?wsdl', true); $dash_api = new dashcs($apiclient); if(!$dash_api) { echo $dash_api->apierror; } // check first the authentication if($dash_api->dashCallMethod('getAuthenticationCheck')) { echo "API Error: $apierror"; print_r($dash_api->apiresult); }else{ print_r($dash_api->apiresult); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/223047-fatal-error-call-to-a-member-function-call-on-a-non-object/ Share on other sites More sharing options...
beegro Posted January 13, 2011 Share Posted January 13, 2011 You're passing the constructor argument by reference, which is unnecessary because you're then storing it as an attribute in the class. This may also be causing the element to fall out of scope though I don't know for sure. Try passing the constructor argument by value instead. Quote Link to comment https://forums.phpfreaks.com/topic/223047-fatal-error-call-to-a-member-function-call-on-a-non-object/#findComment-1159080 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.