salesforce API帐户创建

| 我们已经为Salesforce提供的WSDL文件创建了C#类。 生成的大多数类都是实体类,但是似乎您没有任何调用方法,例如CreateAccount或UpdateAccount。 那是对的吗?您是否使用查询直接进行所有数据操作?     
已邀请:
Salesforce提供了一种通用的create方法,该方法接受通用对象的输入,该通用对象的类型可以是account或contact或任何自定义对象,而不是为每个对象具有单独的create方法。
/// Demonstrates how to create one or more Account records via the API  

public void CreateAccountSample()
{
    Account account1 = new Account();
    Account account2 = new Account();

    // Set some fields on the account1 object. Name field is not set  

    // so this record should fail as it is a required field.  

    account1.BillingCity = \"Wichita\";
    account1.BillingCountry = \"US\";
    account1.BillingState = \"KA\";
    account1.BillingStreet = \"4322 Haystack Boulevard\";
    account1.BillingPostalCode = \"87901\";

    // Set some fields on the account2 object  

    account2.Name = \"Golden Straw\";
    account2.BillingCity = \"Oakland\";
    account2.BillingCountry = \"US\";
    account2.BillingState = \"CA\";
    account2.BillingStreet = \"666 Raiders Boulevard\";
    account2.BillingPostalCode = \"97502\";

    // Create an array of SObjects to hold the accounts  

    sObject[] accounts = new sObject[2];
    // Add the accounts to the SObject array  

    accounts[0] = account1;
    accounts[1] = account2;

    // Invoke the create() call  

    try
    {
        SaveResult[] saveResults = binding.create(accounts);

        // Handle the results  

        for (int i = 0; i < saveResults.Length; i++)
        {
            // Determine whether create() succeeded or had errors  

            if (saveResults[i].success)
            {
                // No errors, so retrieve the Id created for this record  

                Console.WriteLine(\"An Account was created with Id: {0}\",
                    saveResults[i].id);
            }
            else
            {
                Console.WriteLine(\"Item {0} had an error updating\", i);

                // Handle the errors  

                foreach (Error error in saveResults[i].errors)
                {
                    Console.WriteLine(\"Error code is: {0}\",
                        error.statusCode.ToString());
                    Console.WriteLine(\"Error message: {0}\", error.message);
                }
            }
        }
    }
    catch (SoapException e)
    {
        Console.WriteLine(e.Code);
        Console.WriteLine(e.Message);
    }
}  `
    
对,那是正确的。这些对象中没有任何方法,所有操作都将使用其api(网络服务)完成。 这是Java和C#中的一些示例代码     
大多数类,例如“客户”,“联系人”等实际上只是通过网络传输的数据结构。 SforceService(如果您使用的是Web引用,不确定使用WCF调用什么类),则是使用它们执行操作的入口点,例如,您可以将Accounts列表传递给create方法以创建它们在Salesforce方面,Web服务API文档中有许多示例。 查询是只读的,您无法通过查询调用进行更改。     

要回复问题请先登录注册