我正在尝试编写一个简单地连接到 GP WebService 并调用它的 GetCustomerList() 方法来从大平原获取客户的程序。我在下面概述的代码是我在文档中找到的代码的重复,但是,当我运行它时,我得到了一个 SoapException。我不确定我是否缺少凭据(例如用户名和密码),或者我是否正确地调用了它。我相信我在 Dynamics Security Console 中正确设置了安全设置,但我不是 100% 确定或者是否还有其他需要配置的内容。任何帮助将不胜感激。
public IList<string> GetCustomerNames()
{
//Added a ServiceReference to the actual WebService which appears to be working
var service = new DynamicsGPClient();
var context = new Context();
var customerKey = new CustomerKey();
var companyKey = new CompanyKey();
//Trying to load the test data
companyKey.Id = (-1);
context.OrganizationKey = (OrganizationKey)companyKey;
//Trying to load the test data
customerKey.Id = "AARONFIT0001";
var customers = service.GetCustomerList(new CustomerCriteria(), context);
return customers.Select(x => x.Name).ToList();
}