1

I am integrating Sales force in ASP.NET application so here I am using PartnerWSDL for integration but when I quering SOQL language for Lead then how can I retrieve the data from that because I am unable to get Lead class in partnerWSDl so how can I convert my data to Lead varables. Please check the code below

 String soqlQuery = "SELECT Rating,NumberOfEmployees,Industry,Status,LeadSource,Email FROM Lead";
try
{
PartnerWSDL.QueryResult qr = binding.query(soqlQuery);
bool done = false;
if (qr.size > 0)
{  
while (!done)
{
PartnerWSDL.sObject[] records = qr.records;
for (int i = 0; i < records.Length; i++)
{
PartnerWSDL.Lead lead=(PartnerWSDL.Lead)record[i]; ---- this generates an compile time error, that lead class is not defined in PartnerWSDL.
}
}

But in our enterprice we have the Lead, Contact class defined in WSDL.

2

You assign it to an sforce.SObject instead of a designated object class. Here's the example from the API documentation:

public void querySample() 
{
    try
    {
    QueryResult qr = null;
    binding.QueryOptionsValue = new sforce.QueryOptions();
    binding.QueryOptionsValue.batchSize = 250;
    binding.QueryOptionsValue.batchSizeSpecified = true;

    qr = binding.query("SELECT FirstName, LastName FROM Contact");

    bool done = false;
    int loopCount = 0;
    while (!done)
    {
        Console.WriteLine("\nRecords in results set " + 
            Convert.ToString(loopCount++)
                + " - ");
        // Process the query results
        for (int i = 0; i < qr.records.Length; i++)
        {
            sforce.sObject con = qr.records[i];
            string fName = con.Any[0].InnerText;
            string lName = con.Any[1].InnerText;
            if (fName == null)
                Console.WriteLine("Contact " + (i + 1) + ": " + lName);
            else
                Console.WriteLine("Contact " + (i + 1) + ": " + fName
                    + " " + lName);
        }

        if (qr.done)
            done = true;
        else
            qr = binding.queryMore(qr.queryLocator);
    }
}
catch (SoapException e)
{
    Console.WriteLine("An unexpected error has occurred: " + e.Message +
        " Stack trace: " + e.StackTrace);
}
Console.WriteLine("\nQuery execution completed.");
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.