You need to sign in to do that
Don't have an account?
I'm getting error "There is an error in XML document (1, 278)" when running a query
try {
//CREATES THE QUERY TO CALL SF WS
string ls_Query = "SELECT FirstName,LastName,Email " +
"FROM Contact " +
"WHERE Id = '" + as_SFID + "'";
//READS THE URL AND USER VALUES FROM THE WEB CONFIG
string ls_SFURL = "https://test.salesforce.com/services/Soap/u/9.0";
string ls_SFUser = "user";
string ls_SFPassword = "password";
//CREATES THE SF OBJECT
SforceService lo_srvcSF = new SforceService();
lo_srvcSF.Url = ls_SFURL;
//LOGS TO THE SF WS
LoginResult lo_SFLoginResult = lo_srvcSF.login(ls_SFUser,ls_SFPassword);
//SAVES THE SESSION HEADER AND URL
SessionHeader lo_SFSessionHeader = new SessionHeader();
lo_SFSessionHeader.sessionId = lo_SFLoginResult.sessionId;
lo_srvcSF.Url = lo_SFLoginResult.serverUrl;
lo_srvcSF.SessionHeaderValue = lo_SFSessionHeader;
string ls_SFUserID = lo_SFLoginResult.userId;
//SENDS THE QUERY TO THE SF WS
lo_srvcSF.QueryOptionsValue = new QueryOptions();
lo_srvcSF.QueryOptionsValue.batchSize = 500;
lo_srvcSF.QueryOptionsValue.batchSizeSpecified = true;
QueryResult lo_QueryResult = null;
lo_QueryResult = lo_srvcSF.query(ls_Query);
if (lo_QueryResult == null)
throw new Exception("The query retrieved a null result for the Contacts.");
if (lo_QueryResult.size ==0)
throw new Exception("The query retrieved cero records for the Contacts.");
//GETS THE RECORDS RETRIEVED
if (lo_QueryResult.size > 0) {
sObject[] lo_Records = lo_QueryResult.records;
Contact lo_Contact = (Contact)lo_Records[0];
as_FirstName = lo_Contact.FirstName;
as_LastName = lo_Contact.LastName;
as_EMail = lo_Contact.Email;
}
}
catch(Exception Exp) {
throw new Exception("Unable to read the details from Sales Force. The error was: " + Exp.Message);
}
Here is an excerpt from the API documents, page 28.
To access your organization’s Salesforce Sandbox via the API, use the following URLs to make login requests:
• https://test.salesforce.com/services/Soap/c/9.0 (enterprise WSDL)
• https://test.salesforce.com/services/Soap/u/9.0 (partner WSDL)
You should always try and stay current on your version numbers. If you are coding something new you should always use the latest version. There are VERY few times that you will need to stay on an older version, especially when you are coding something new.
The error you are getting is related to a type problem with QueryResult. This is odd as QueryResult is in both the partner WSDL and the Enterprise WSDL. You might want to download your WSDL again and rebuild your proxy class.
JonD
360 Vantage
3115 S. Price Road
Chandler, AZ 85248