我们为Salesforce提供的WSDL文件创建了C#类。创建salesforce API帐户
大部分生成的类都是实体类,但似乎您没有任何方法可以调用,如CreateAccount或UpdateAccount。
这是正确的吗?你是否使用查询直接进行所有数据操作?
我们为Salesforce提供的WSDL文件创建了C#类。创建salesforce API帐户
大部分生成的类都是实体类,但似乎您没有任何方法可以调用,如CreateAccount或UpdateAccount。
这是正确的吗?你是否使用查询直接进行所有数据操作?
Salesforce不是为每个对象分别创建方法,而是提供了一种通用的创建方法,该方法接受通用对象的输入,该通用对象可以是帐户或联系人或任何自定义对象的类型。
/// 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(Web服务)完成的。
Here是Java的一些示例代码和C#
大多数类,如客户,联系人等是真的走了过来线只是数据结构。 SforceService(如果您使用的是Web引用,不知道该类是通过WCF调用的)是用于处理它们的入口点,例如可以将一系列帐户传递给create方法以使其创建销售人员方面,web services API docs中有许多例子。 查询只能读取,不能通过查询调用进行更改。
所以我会说实体类是作为存根存在的,但是你必须编写一个可以编译这些查询的bll层,例如,更新查询,然后使用实体存根将它的值连接到查询? – Jacques 2011-05-25 16:29:03
绑定.describeSObject方法呢? – Jacques 2011-05-25 16:30:55
@Jacques:是的,我们制作了一个图层,用于编译这些查询以加载和保存一个对象,以及一个集合类,它编译用于使用where子句加载对象的查询。 – 2011-05-25 18:03:49