2011-06-15 117 views
0

我在http://social.microsoft.com/Forums/en-US/crmdevelopment/thread/d5d00302-8f7b-4efc-873b-c54b3e29749d問了同樣的問題,但沒有得到答案。所以,我會再次嘗試在stackoverflow。CRM 2011 Dicovery服務FaultException

我正在運行crm 2011培訓工具包中的示例代碼。

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; 

在VAR響應線= dsp.Execute(orgRequest),我得到了FaltException`1,詳細信息如下

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) 

我能夠訪問Discovery.svc文件使用瀏覽器。所以服務器網址應該是正確的。這是一個身份驗證問題嗎?

回答

1

這是用於Microsoft CRM Online還是內部部署?對於網絡,我知道你想什麼在SDK中使用的東西線沿線的 -

// Connect to the Discovery service. 
// The using statement assures that the service proxy will be properly disposed. 
using (DiscoveryServiceProxy _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); 
} 

有對DiscoveryServiceProxy類重載,但如果你提供你要連接什麼一些更多的細節到,我想它會縮小它的範圍。

+0

這是一個內部部署。我嘗試了SDK中的代碼,它運行良好。我現在正在使用SDK示例代碼並嘗試查找導致錯誤的確切位置。 – 2011-06-16 16:18:36

+0

請求的AccessType和Release參數對我來說是個問題。謝謝! – BeardinaSuit 2012-01-22 23:54:49