none
CRM 2011 Dicovery Service FaultException

    Question

  • I was running the example code from the training kit.

     

     var creds = new ClientCredentials();
     var dsp = new DiscoveryServiceProxy( dinfo, creds);
     dsp.Authenticate();
     var orgRequest = new RetrieveOrganizationRequest();
      var response = dsp.Execute(orgRequest);
     var orgResponse = response as RetrieveOrganizationsResponse;
     if (orgResponse != null)
     comboOrgs.ItemsSource = orgResponse.Details;

     

     

     

     

    At the bold line, I got the FaltException`1, the detailed message is as follows

     

    System.ServiceModel.FaultException`1 was unhandled
     Message=organizationName
     Source=mscorlib
     Action=http://schemas.microsoft.com/xrm/2011/Contracts/Discovery/IDiscoveryService/ExecuteDiscoveryServiceFaultFault
     StackTrace:
     Server stack trace: 
     at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
     at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
     at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
     at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
     Exception rethrown at [0]: 
     at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
     at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
     at Microsoft.Xrm.Sdk.Discovery.IDiscoveryService.Execute(DiscoveryRequest request)
     at Microsoft.Xrm.Sdk.Client.DiscoveryServiceProxy.Execute(DiscoveryRequest request)
    

     

     

    I was able to access the Discovery.svc file using browser. So the server url should be correct. Is this an authentication problem?

     

     

     




    Wednesday, June 15, 2011 9:36 PM

Answers

  • var creds = new ClientCredentials(); 
    var dsp = new DiscoveryServiceProxy( dinfo, creds); dsp.Authenticate();
    var orgRequest = new RetrieveOrganizationRequest();
    var response = dsp.Execute(orgRequest);
    var orgResponse = response as RetrieveOrganizationsResponse;
    if (orgResponse != null)
    comboOrgs.ItemsSource = orgResponse.Details;
      The bold line above is the cause of all the evil. I should can initialized as  new RetrieveOrganizationsRequest() instead of new RetrieveOrganizationRequest(). Notice the bold and undlined little "s".
    Thursday, June 16, 2011 6:51 PM

All replies

  • Try setting the credentials this way

    var creds = new ClientCredentials();
    creds.Windows.ClientCredential = new NetworkCredential("username", "password", "domain");
     var dsp = new DiscoveryServiceProxy( dinfo, creds);
    
    

     

    Thursday, June 16, 2011 6:47 AM
  • I tried setting credential but got no luck either. Interesting, the sample code came with SDK worked. I am now investigating the SDK code trying to pin down the exact cause of the error.
    Thursday, June 16, 2011 4:20 PM
  • Can you post how you set dinfo?
    Blake Scarlavai - http://mscrmdev.blogspot.com/ - Sonoma Partners - http://www.sonomapartners.com/
    Thursday, June 16, 2011 5:00 PM


  • IServiceConfiguration<IDiscoveryService> dinfo = ServiceConfigurationFactory.CreateConfiguration<IDiscoveryService>(GetDiscoveryServiceUri(ServerURL.Text));

    Where GetDiscoverServiceUri returns a

    new Uri("host url"+"/XRMServices/2011/Discovery.svc");


     

    Thursday, June 16, 2011 5:25 PM
  • var creds = new ClientCredentials(); 
    var dsp = new DiscoveryServiceProxy( dinfo, creds); dsp.Authenticate();
    var orgRequest = new RetrieveOrganizationRequest();
    var response = dsp.Execute(orgRequest);
    var orgResponse = response as RetrieveOrganizationsResponse;
    if (orgResponse != null)
    comboOrgs.ItemsSource = orgResponse.Details;
      The bold line above is the cause of all the evil. I should can initialized as  new RetrieveOrganizationsRequest() instead of new RetrieveOrganizationRequest(). Notice the bold and undlined little "s".
    Thursday, June 16, 2011 6:51 PM