Quantcast
Channel: Exchange Server Development forum
Viewing all articles
Browse latest Browse all 7132

Autodiscover Service The Autodiscover service couldn't be located error while connecting using EWS 2.0

$
0
0

Hi ,

Until Exchange 2010 SP1 I was using with success the API 2.0 which I was connecting in Office 365.

After the upgrade in Exchange 2013 and without changing any of my programming code I 'm starting getting the "The Autodiscover service couldn't be located." error.

In my code I'm using a loop , to loop through all of my users . In the First three users everything is working fine.

But after the third or sometimes the fourth or fifth (completely random case) I'm starting getting the error.

this is the  code I'm using to connect to Offcie 365

 Dim service = New ExchangeService
                service = GetBinding()

Public Function GetBinding() As ExchangeService
        ' Create the binding.
        'Me.ExchangeVersion1 = 4
        Dim service As New ExchangeService(Me.ExchangeVersion1)

        ' Define credentials.
        service.Credentials = New WebCredentials(UserName, PassWord)

        If Me.UseTrace Then
            Dim TC As New EWSTrace.TraceListener
            TC.TracePath = Me.TracePath
            service.TraceFlags = TraceFlags.All
            service.TraceEnabled = True
            service.TraceListener = TC

        End If

        ' Use the AutodiscoverUrl method to locate the service endpoint.

        'Code used to work like that.
        Try
            service.AutodiscoverUrl(UserName, _
                    New AutodiscoverRedirectionUrlValidationCallback( _
                        AddressOf Exchange2010.RedirectionUrlValidationCallback))
            '   Me.ExchangeVersion1 = 3
        Catch ex As AutodiscoverRemoteException
            Me.ErrorCode = -1
            Me.SetErrorMessage(ex.Message)
            Throw ex
        End Try


        
        Return service
    End Function

    ' Create the callback to validate the redirection URL.
    Private Shared Function RedirectionUrlValidationCallback(ByVal redirectionUrl As String) As Boolean
        ' Perform validation.
        Return (redirectionUrl = _
                "https://autodiscover-s.outlook.com/autodiscover/autodiscover.xml")
    End Function

Which the above code is correct . And it is working - worked until the upgrade. The exchange version is correct( Im assigning the properties correct so let's not focus in there).

An this the stack I'm getting.

HRersult  = -2146233088
   at Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverService.InternalGetLegacyUserSettings[TSettings](String emailAddress, List`1 redirectionEmailAddresses, Int32& currentHop)
   at Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverService.GetLegacyUserSettings[TSettings](String emailAddress)
   at Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverService.InternalGetLegacyUserSettings(String emailAddress, List`1 requestedSettings)
   at Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverService.GetUserSettings(String userSmtpAddress, UserSettingName[] userSettingNames)
   at Microsoft.Exchange.WebServices.Data.ExchangeService.GetAutodiscoverUrl(String emailAddress, ExchangeVersion requestedServerVersion, AutodiscoverRedirectionUrlValidationCallback validateRedirectionUrlCallback)
   at Microsoft.Exchange.WebServices.Data.ExchangeService.AutodiscoverUrl(String emailAddress, AutodiscoverRedirectionUrlValidationCallback validateRedirectionUrlCallback)
   at Exchange2010.Exchange2010.GetBinding() in C:\test\WEBDAV_COM\EXCHANGE_2010\Exchange2010_COM\Exchange\Exchange2010.vb:line 1328
   at Exchange2010.Exchange2010.ConnectWithExchange() in C:\test\WEBDAV_COM\EXCHANGE_2010\Exchange2010_COM\Exchange\Exchange2010.vb:line 715

Appreciate any help you could give me.

thank you


Viewing all articles
Browse latest Browse all 7132

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>