Force.com-Toolkit-for-PHP
Force.com-Toolkit-for-PHP copied to clipboard
Query : Throw Exception SoapFault Object ( [message:protected] => Element {}item invalid at this location
I am using enterprise and able to login using mySforceConnection->login method. But when try to execute query using query mySforceConnection->query i got below exception.
SoapFault Object ( [message:protected] => Element {}item invalid at this location [string:Exception:private] => [code:protected] => 0 [file:protected] => /payment/soapclient/SforceBaseClient.php [line:protected] => 808 [trace:Exception:private] => Array ( [0] => Array ( [file] => /payment/soapclient/SforceBaseClient.php [line] => 808 [function] => __call [class] => SoapClient [type] => -> [args] => Array ( [0] => query [1] => Array ( [0] => Array ( [queryString] => Select Name, zqu__BillToContact__c, zqu__BillToContact__r.Email, Contact_Email__c From zqu__Quote__c ) ) ) ) [1] => Array ( [file] => /payment/soapclient/SforceBaseClient.php [line] => 808 [function] => query [class] => SforceSoapClient [type] => -> [args] => Array ( [0] => Array ( [queryString] => Select Name, zqu__BillToContact__c, zqu__BillToContact__r.Email, Contact_Email__c From zqu__Quote__c ) ) ) [2] => Array ( [file] => /payment/enterprise.php [line] => 24 [function] => query [class] => SforceBaseClient [type] => -> [args] => Array ( [0] => Select Name, zqu__BillToContact__c, zqu__BillToContact__r.Email, Contact_Email__c From zqu__Quote__c ) ) ) [previous:Exception:private] => [faultstring] => Element {}item invalid at this location [faultcode] => soapenv:Client )
Can you post your code for the login and query?
Thanks for your quick reply. Here is my code.
define("SOAP_CLIENT_BASEDIR", "./soapclient");
$USERNAME='My User Name';
$PASSWORD="My Password ";
$SECURITY_TOKEN="Token Goes here";
require_once (SOAP_CLIENT_BASEDIR.'/SforcePartnerClient.php');
require_once (SOAP_CLIENT_BASEDIR.'/SforceHeaderOptions.php');
try {
$mySforceConnection = new SforcePartnerClient();
$mySoapClient = $mySforceConnection->createConnection(SOAP_CLIENT_BASEDIR.'/enterprise.wsdl.xml');
$mylogin = $mySforceConnection->login($USERNAME, $PASSWORD.$SECURITY_TOKEN);
print_r($mySforceConnection);
echo "<hr>";
$mySforceConnection->printDebugInfo();
echo "<hr>";
$query = 'Select Name, zqu__BillToContact__c, zqu__BillToContact__r.Email, Contact_Email__c From zqu__Quote__c';
$response = $mySforceConnection->query($query);
foreach ($response->records as $record) {
print_r($record);
print_r("<br>");
}
} catch (Exception $e) {
print_r($e);
echo "<hr>";
}
Check the API name of the 'Contact Email' field. Your other custom fields have the zqu__ prefix. I'm guessing your query should be
$query = 'Select Name, zqu__BillToContact__c, zqu__BillToContact__r.Email, zqu__Contact_Email__c From zqu__Quote__c';