function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ 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_ . '' . _WS_NAME_);
define("_WS_NAMESPACE_", '' . _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