我正在尝试使用此代码从服务器获取组织列表:
var clientCredentials = new ClientCredentials();
clientCredentials.Windows.ClientCredential.Domain = "domain";
clientCredentials.Windows.ClientCredential.UserName = "user";
clientCredentials.Windows.ClientCredential.Password = "password";
var discoveryUri = new Uri(String.Format("http://{0}/XRMServices/2011/Discovery.svc", "10.20.30.40"));
var discoveryServiceProxy = new DiscoveryServiceProxy(discoveryUri, null, clientCredentials, null);
discoveryServiceProxy.Authenticate();
var retrieveOrganizationResponse = (RetrieveOrganizationsResponse)discoveryServiceProxy.Execute(new RetrieveOrganizationRequest());
但是在最后一行引发了这个错误:
ORGANIZATIONNAME
异常类型是这样的:
请帮助解决此问题。
答案 0 :(得分:0)
我认为这可能与您构成new RetrieveOrganizationRequest()
的方式有关 - 具体而言,您不会提供任何论据。
有一个示例here,其中显示了如何从发现服务中获取组织列表。
// Retrieve details about all organizations discoverable via the
// Discovery service.
RetrieveOrganizationsRequest orgsRequest =
new RetrieveOrganizationsRequest()
{
AccessType = EndpointAccessType.Default,
Release = OrganizationRelease.Current
};
RetrieveOrganizationsResponse organizations =
(RetrieveOrganizationsResponse)service.Execute(orgsRequest);
// Print each organization's friendly name, unique name and URLs
// for each of its endpoints.
Console.WriteLine();
Console.WriteLine("Retrieving details of each organization:");
foreach (OrganizationDetail organization in organizations.Details)
{
Console.WriteLine("Organization Name: {0}", organization.FriendlyName);
Console.WriteLine("Unique Name: {0}", organization.UniqueName);
Console.WriteLine("Endpoints:");
foreach (var endpoint in organization.Endpoints)
{
Console.WriteLine(" Name: {0}", endpoint.Key);
Console.WriteLine(" URL: {0}", endpoint.Value);
}
}