public void Run(ServerConnection.Configuration serverConfig, bool promptforDelete) { try { // Connect to the Discovery service. // The using statement assures that the service proxy will be properly disposed. using (_serviceProxy = new DiscoveryServiceProxy(serverConfig.DiscoveryUri, serverConfig.HomeRealmUri, serverConfig.Credentials, serverConfig.DeviceCredentials)) { // You can choose to use the interface instead of the proxy. IDiscoveryService service = _serviceProxy; #region RetrieveOrganizations Message // 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); } } Console.WriteLine("End of listing"); Console.WriteLine(); #endregion RetrieveOrganizations Message #region RetrieveOrganization Message // Retrieve details about a single organization discoverable via the Discovery service. // RetrieveOrganizationRequest orgRequest = new RetrieveOrganizationRequest() { UniqueName = organizations.Details[organizations.Details.Count -1].UniqueName, AccessType = EndpointAccessType.Default, Release = OrganizationRelease.Current }; RetrieveOrganizationResponse org = (RetrieveOrganizationResponse)service.Execute(orgRequest); // Print the organization's friendly name, unique name and URLs // for each of its endpoints. Console.WriteLine(); Console.WriteLine("Retrieving details of specific organization:"); Console.WriteLine("Organization Name: {0}", org.Detail.FriendlyName); Console.WriteLine("Unique Name: {0}", org.Detail.UniqueName); Console.WriteLine("Endpoints:"); foreach (KeyValuePair<EndpointType, string> endpoint in org.Detail.Endpoints) { Console.WriteLine(" Name: {0}", endpoint.Key); Console.WriteLine(" URL: {0}", endpoint.Value); } Console.WriteLine("End of listing"); Console.WriteLine(); #endregion RetrieveOrganization Message } } // Catch any service fault exceptions that Microsoft Dynamics CRM throws. catch (FaultException<Microsoft.Xrm.Sdk.DiscoveryServiceFault>) { // You can handle an exception here or pass it back to the calling method. throw; } }
Friday, 6 October 2017
discovery service code
Subscribe to:
Post Comments (Atom)
Have you ever faced an issue where you need to import some record without changing GUID of the record? For example if we need to migr...
-
Sometimes we got requirements which include more than one request in custom code. And we generally used service.Create and service.Upd...
-
Have you ever got below error message while you trying to upload new report??? Some day ago I got a urgent issue from my Client to c...
-
The Microsoft Dynamics CRM SDK Templates provide project and item templates for creating a number of SDK centric CRM components. This t...
No comments:
Post a Comment