Dynamics 365 DiscoveryServiceProxy有时不返回任何结果

时间:2017-05-12 19:29:06

标签: .net vb.net crm dynamics-crm-online dynamics-365

首先发帖所以请善待。

我试图在Dynamics 365(在线)中返回用户有权访问的组织列表。

这个功能大约有50%的时间可以运行,它可以正常验证,并返回组织列表,但随机它根本不会返回任何组织。

我使用格式为XXX@XXX.onmicrosoft.com的登录,访问动态365本身就没问题。

我已经有了组织端点,可以很好地创建组织服务,只是努力从功能中获得一致的结果。

我已经调查了服务上的任何类型的最大呼叫尝试,使用fiddler跟踪任何线索的请求和响应,但到目前为止没有任何错误。没有错误。

任何帮助都会被认定

Public Shared Function retrieveOrganizations(conn As Connectiondata) As List(Of orgDetails)

    ' New Org List
    Dim orgList As New List(Of orgDetails)

    ' Accepts all certs
    ServicePointManager.ServerCertificateValidationCallback = New RemoteCertificateValidationCallback(Function() True)

    ' Create a management service
    Dim serviceManagement As IServiceManagement(Of IDiscoveryService) = ServiceConfigurationFactory.CreateManagement(Of IDiscoveryService)(New Uri("https://disco.crm11.dynamics.com/XRMServices/2011/Discovery.svc"))

    ' Find what type of endpoint we need to use
    Dim endpointType As AuthenticationProviderType = serviceManagement.AuthenticationType

    ' Set the credentials based on the auth type and conn details
    Dim authCredentials As AuthenticationCredentials = GetCredentials(serviceManagement, endpointType, conn)

    'Create discovery service proxy
    Dim discoService As New DiscoveryServiceProxy(serviceManagement, authCredentials.ClientCredentials)

    ' Authenticate the service
    discoService.Authenticate()

    'Retrieve Organization details
    Dim orgRequest As New RetrieveOrganizationsRequest()

    ' Cast the response
    Dim allOrgs As RetrieveOrganizationsResponse = DirectCast(discoService.Execute(orgRequest), RetrieveOrganizationsResponse)

    'Print all organization(s)(instances) endpoint.
    For Each orgdetail As OrganizationDetail In allOrgs.Details

        ' Create a new object
        orgList.Add(New orgDetails With {.friendlyName = orgdetail.FriendlyName, .ID = orgdetail.OrganizationId.ToString})

    Next

    ' Return the list
    Return orgList

End Function

0 个答案:

没有答案