+ Start a Discussion

Ooop! Error: System.NullPointerException: Attempt to de-reference a null object Class.Ctest.cInsert


    we are connecting from php to salesforce,while connecting we are getting an error is
  Ooop! Error: System.NullPointerException: Attempt to de-reference a null object Class.Ctest.cInsert: line  a1.Name = req.accName;

 My Webservice class
global class Ctest
// Request Class
global class RequestClass
  webservice String accName;
// Response Class
global class ResponseClass
webservice String acName;

RequestClass req = new RequestClass();
webservice static ResponseClass  cInsert(RequestClass req)
 ResponseClass res = new ResponseClass();
   Account a1 = new Account();
   a1.Name = req.accName; // Error showing point
    insert a1;
  // Return Response
   res.acName = a1.Name;
   return res;

And my php code is


$sfdc = new SforceEnterpriseClient();
$SoapClient = $sfdc->createConnection('enterprise.wsdl.xml');

$loginResult = false;

$loginResult = $sfdc->login(USER, PASSWORD . SECURITY_KEY);

$parsedURL = parse_url($sfdc->getLocation());
define("_SFDC_SERVER_", substr($parsedURL['host'], 0, strpos($parsedURL['host'], '.')));
define("_WS_NAME_", 'salesforceAPI/Ctest');
define("_WS_WSDL_", _WS_NAME_ . '.xml');
define("_WS_ENDPOINT_", 'https://' . _SFDC_SERVER_ . '.salesforce.com/services/wsdl/class/' . _WS_NAME_);
define("_WS_NAMESPACE_", 'http://soap.sforce.com/schemas/class/' . _WS_NAME_);

$client = new SoapClient(_WS_WSDL_);
$sforce_header = new SoapHeader(_WS_NAMESPACE_, "SessionHeader", array("sessionId" => $sfdc->getSessionId()));

$method = $client->__getFunctions();

$wsParams = array('accName' => 'XXXXXXX');


With debug statements can you check what value are you getting for req.accName? 


   Can you suggest me how to check with debug statements in developer console for above webservice