简体   繁体   English

Microsoft Dynamics 365 OrganizationName异常

[英]Microsoft Dynamics 365 organizationName exception

I'm trying to get the list of organizations from a server using this code: 我正在尝试使用以下代码从服务器获取组织列表:

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());

but in the last line throws this error: 但在最后一行抛出此错误:

organizationName 机构名称

the Exception type is this: 异常类型是这样的:

http://schemas.microsoft.com/xrm/2011/Contracts/Discovery/IDiscoveryService/ExecuteDiscoveryServiceFaultFault http://schemas.microsoft.com/xrm/2011/Contracts/Discovery/IDiscoveryService/ExecuteDiscoveryServiceFaultFault

Please your help with this issue. 请您帮助解决此问题。

I think it might be to do with how your are forming the new RetrieveOrganizationRequest() - specifically, that your don't supply any arguments. 我认为这可能与您如何形成new RetrieveOrganizationRequest() ,特别是您不提供任何参数。

There is an example here , that shows how to get the list of organizations from the Discovery Service. 有一个例子在这里 ,那就说明如何获得从发现服务机构名单。

// 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);
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM