Test the disponibility of an organisation in c# RRS feed

  • Question

  • Hi!

    I work on a WCF application and I would like to write a function to test the availability of an organization through a wcf webservice and return a message if it has available or not. I'm new in the software development.
    Could you help me about this by show me a sample code who do that?

    Monday, December 7, 2015 3:44 PM


All replies

  • It depends if you want to check if the organization is enabled or exists, or if you instead just want to check if it will respond to a request (e.g. checking something like network issues).

    If you just want to check if it is enabled/available you could just use the discovery service and a RetrieveOrganizationsRequest as per this URL https://msdn.microsoft.com/en-us/library/microsoft.xrm.sdk.discovery.retrieveorganizationsrequest.aspx. Just check that it returns your organization.

    If it's something more fundamental you're checking for, like network / connectivity issues, then you could simply run a WhoAmIRequest on an Organization Service Proxy to make sure you can get a response from the service (https://msdn.microsoft.com/en-us/library/microsoft.crm.sdk.messages.whoamirequest.aspx). 

    If you're unsure on how to connect to your organization you might want to review the SDK to see how the Organization Service and Discovery Service web services work.




    Monday, December 7, 2015 4:07 PM
  • Thanks for your reply.

    But there are certains parts of the samples I don't understand. I'm new in development.

    Could you write an example for me? What I want is to check if it will respond to a request (network issues).


    Monday, December 7, 2015 5:58 PM
  • A very simple connect and test a request could look something like this:

    var cred = new ClientCredentials();
    cred.Windows.ClientCredential.Domain = "[Domain]";
    cred.Windows.ClientCredential.UserName = "[UserName]";
    cred.Windows.ClientCredential.Password = "[Password]";
    Uri crmOrgUri = new Uri("http://[your server]/[organization name]/XRMServices/2011/Organization.svc");
    _serviceProxy = new OrganizationServiceProxy(crmOrgUri, null, cred, null);
        var response = _serviceProxy.Execute(new WhoAmIRequest());
    catch (Exception ex)
        // A problem occurred!

    Where you need to replace the domain, username, password, server and organization name to those relevant to you.

    Hope that helps!


    Tuesday, December 8, 2015 1:50 PM