简体   繁体   English

php:System.NullPointerException:尝试取消引用空对象

[英]php : System.NullPointerException: Attempt to de-reference a null object

Please help me to sort out this problem I am getting this error. 请帮助我解决此问题,我收到此错误。 [faultstring] => System.NullPointerException: Attempt to de-reference a null object I am using custom object integration for Sales force. [faultstring] => System.NullPointerException:尝试取消引用空对象我正在使用Salesforce的自定义对象集成。

            require_once ('soapclient/SforcePartnerClient.php');
            require_once ('soapclient/SforceHeaderOptions.php');

            try {

            $mySforceConnection = new SforcePartnerClient();
            $mySforceConnection->createConnection("soapclient/partnerwsdl-sb.xml");
            $mySforceConnection->login(USERNAME, PASSWORD.SECURITY_TOKEN);
            // Define constants for the web service. We'll use these later
            $parsedURL = parse_url($mySforceConnection->getLocation());
            define ("_SFDC_SERVER_", substr($parsedURL['host'],0,strpos($parsedURL['host'], '.')));
            define ("_WS_NAME_", 'WebToLeadServices');
            define ("_WS_WSDL_", 'soapclient/WebToLeadServices-SB-V1.1.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_);


            // SOAP Client for Web Service

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

            $client->__setSoapHeaders(array($sforce_header));
             $sObject = new stdclass();
            $sObject->fullName = 'Sunil';
            $sObject->country = 'India';
            $sObject->budget = '1';
            $sObject->type = 'Contact';
            $sObject->dialingCode = '91';
            $sObject->emailAddress = "XXXX";
            $sObject->mobileNumber = "XXXXXXXX";
            $sObject->source = "google";
            $sObject->projectInterested = "Project";
            $sObject->capturePoint = "XXXX.php";
            $sObject->IPAddress = "XXXX";
            $sObject->webbannerSource = "google";
            $sObject->webbannerSize = "twitter"; 
              $createResponse = $client->createLeadFromWeb(array($sObject));

            } catch (Exception $e) {
                    echo '<pre>';
            print_r($e);
            echo '</pre>';
            }
            ?>
    </pre>

I have got the solution for it We need to pass the variable like this with required field. 我已经有了解决方案,我们需要将这样的变量与必填字段一起传递。
and its working 及其工作

$lead = new StdClass();
$lead->fullName = 'sunil';
$lead->mobileNumber = "1234567896";
$lead->emailAddress = "sunil@example.in";
$lead->source = "DIGITAL MARKETING";
$leadData = array('wl'=>$lead);
$response = $client->createLeadfromWeb($leadData);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 尝试取消引用空对象 Salesforce Visual Force 页面 - Attempt to de-reference a null object Salesforce Visual Force Page java.lang.NullPointerException:尝试在空对象引用上调用虚拟方法 - java.lang.NullPointerException: Attempt to invoke virtual method on a null object reference java.lang.NullPointerException:尝试在空对象引用上调用虚拟方法&#39;int org.json.JSONObject.getInt(java.lang.String)&#39; - java.lang.NullPointerException: Attempt to invoke virtual method 'int org.json.JSONObject.getInt(java.lang.String)' on a null object reference PHP插入到MySQL查询尝试返回Null - PHP Insert Into Returns Null on MySQL Query Attempt 在PHP中通过空引用传递 - Pass by null reference in PHP 警告:从空值创建默认值 object,在 PHP 8 我收到严重未捕获错误:尝试在 null 上分配属性“长度” - Warning: Creating default object from empty value, in PHP 8 I get CRITICAL Uncaught Error: Attempt to assign property "length" on null PHP SOAP错误消息-System.NullReferenceException:对象引用未设置为对象的实例 - PHP SOAP Errormessage - System.NullReferenceException: Object reference not set to an instance of an object 使用PHP的参考号系统 - Reference number system using PHP JSON Android错误-尝试在空对象引用上调用虚拟方法&#39;java.lang.String org.json.JSONObject.getString(java.lang.String)&#39; - JSON Android Error- Attempt to invoke virtual method 'java.lang.String org.json.JSONObject.getString(java.lang.String)' on a null object reference 在PHP中返回对象的引用 - Returning a reference to an object in PHP
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM