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
iliveinhopeiliveinhope 

Sforce Query problem

Hi folks,

i tried to query sforce db via the web service. I got the following error message. My code is a simple demo example. there shoudln't be anything wrong with the query (C# code is pended after the error message). I appricate if any of you can help me resolve this problem and getting some returns from the sforce db.

***********************************************************************************
The specified type was not recognized: name='sObject', namespace='urn:sobject.partner.soap.sforce.com', at .
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: The specified type was not recognized: name='sObject', namespace='urn:sobject.partner.soap.sforce.com', at .

Source Error:

Line 304: [return: System.Xml.Serialization.XmlElementAttribute("result")]
Line 305: public QueryResult query(string queryString) {
Line 306: object[] results = this.Invoke("query", new object[] {
Line 307: queryString});
Line 308: return ((QueryResult)(results[0]));


Source File: c:\inetpub\wwwroot\performlocal\web references\sforce\reference.cs Line: 306

Stack Trace:

[InvalidOperationException: The specified type was not recognized: name='sObject', namespace='urn:sobject.partner.soap.sforce.com', at .]
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read20_sObject(Boolean isNullable, Boolean checkType) +2463
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read89_QueryResult(Boolean isNullable, Boolean checkType) +601
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read142_queryResponse() +308

[InvalidOperationException: There is an error in XML document (8, 6).]
System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle)
System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader)
System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
PerformLocal.sforce.SforceService.query(String queryString) in c:\inetpub\wwwroot\performlocal\web references\sforce\reference.cs:306
PerformLocal.ConvertExecutiveNames.contactQuery() in c:\inetpub\wwwroot\performlocal\convertexecutivenames.aspx.cs:213
PerformLocal.ConvertExecutiveNames.testQuery_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\performlocal\convertexecutivenames.aspx.cs:246
System.Web.UI.WebControls.Button.OnClick(EventArgs e)
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
System.Web.UI.Page.ProcessRequestMain()
*****************************************************************************************



private void contactQuery() {
sforce.SforceService binding = new sforce.SforceService();
binding.SessionHeaderValue = new sforce.SessionHeader();

try {
binding.SessionHeaderValue.sessionId = UserSession.GetUserSession().SessionID;
binding.Url = UserSession.GetUserSession().ServerAddress;
}
catch (Exception ex) {
ErrorHandler handler = new ErrorHandler();
handler.HandleException(ex);
}

// Set the query options (Optional; default batch size is 2000)
binding.QueryOptionsValue = new sforce.QueryOptions();
binding.QueryOptionsValue.batchSize = 10;
binding.QueryOptionsValue.batchSizeSpecified = true;

// Invoke the query call and save the result in a QueryResult

sforce.QueryResult qr = binding.query("select Name, numberOfEmployees, Id, Industry from Account");

// Get the returned records
sforce.sObject[] records = qr.records;

// Determine whether some records where returned
if (records.Length > 0) {
bool done = false; // Use this for loop control
while (!done) {
for (int i=0; i sforce.Contact contact = (sforce.Contact)records[i];
message.Text = (contact.FirstName + " " +
contact.LastName);
}
// Update the loop control
done = qr.done;
// Determine whether we need to retrieve another batch of result records
if (done == false) {
qr = binding.queryMore(qr.queryLocator);
records = qr.records;
}
else {
done = qr.done;
}

}
}
else {
System.Diagnostics.Trace.WriteLine("no records matched criteria");
}
}
DevAngelDevAngel

Hi iliveinhope,

This sounds like you have a mixed endpoint problem.  This means that you are sending enterprise messages to the partner endpoint or vice versa.  This can happen if you use the wrong url after the login call.

Check your generated proxy and inspect the url prior to making your query.

iliveinhopeiliveinhope
DevAngel:

I checked the URL I set, it is: https://na1.salesforce.com/services/Soap/u/5.0

I read some other posts on this board. I think "u" is the enterprise service. Is that correct? What else can casue this problem?

Thanks.

Message Edited by iliveinhope on 04-28-2005 11:18 AM

SuperfellSuperfell
u is for the partner API