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
Developer99Developer99 

Element {} item is invalid Can anyone explain this error ?

Hi,

      When we are connecting to sfdc using the SOAP API we are receiving an error message:

   


ini_set("soap.wsdl_cache_enabled", "0");
ini_set(E_ALL,1);
ini_set('display_errors',1);


// Include the PHP Toolkit
require_once('salesforceAPI/soapclient/SforcePartnerClient.php');
require_once('salesforceAPI/soapclient/SforceHeaderOptions.php');

// Login
define('USER','dddd@sfdc.com');
define('PASSWORD', 'defr234');
define('SECURITY_KEY', 'awed2341xIm3WAoq6I6XoHxG');

//echo userName;
//echo password;
//echo securitytoken;

$sfdc = new SforcePartnerClient();
$SoapClient = $sfdc->createConnection('salesforceAPI/partner.wsdl.xml');

$loginResult = false;

try {
    // log in with username, password and security token if required
   $loginResult = $sfdc->login(USER, PASSWORD . SECURITY_KEY);
} catch (Exception $e) {
    global $errors;
    $errors = $e->faultstring;
    echo "Fatal Login Error <b>" . $errors . "</b>";
    die;
}

// Define constants for the web service. We'll use these later
$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()));
$client->__setSoapHeaders(array($sforce_header));

$method = $client->__getFunctions();
echo _SFDC_SERVER_."<br>";
echo _WS_NAME_."<br>";
echo _WS_WSDL_."<br>";
echo _WS_ENDPOINT_."<br>";
echo _WS_NAMESPACE_."<br>";
//
try {

    $wsParams=array('name' =>'hhhi');
    // call the web service via post
    $client->cInsert($wsParams);

// this is really bad.
} catch (Exception $e) {
    global $errors;
    $errors = $e->faultstring;
    echo "Ooop! Error: <b>" . $errors . "</b>";
    die;
}
Ashish_SFDCAshish_SFDC
HI , 


It Basically means that the Connection to the partner.wsdl.xml is failing. 

See the below links for more information and related threads, 

http://stackoverflow.com/questions/20628669/salesforce-element-item-invalid-at-this-location

http://sfdc.arrowpointe.com/2008/12/05/calling-apex-web-services-from-php/

https://github.com/ddeboer/DdeboerSalesforceMapperBundle/issues/10

https://drupal.org/node/1922260


Regards,
Ashish