EWS error gettingEvents

Im having an issue with Office 365 EWS (its only Office 365, Exchange 2010 and 2013 work fine).  I can create my pull subscription without error but when I go to use it by calling

getEvents()


I receivean error:

ErrorNoRespondingCASInDestinationSite

The following error occured while retrieving events for exchange resource: <room address> - Exchange Web Services are not currently available for this request because none of the Client Access Servers in the destination site could process the request.

Here is some code snippets

Using autodiscover and setting up credentials

this.exchangeService.Credentials = new NetworkCredential(this.Username, this.Password);
                    try {
                        this.exchangeService.AutodiscoverUrl(this.Username, RedirectionCallback);
                    }
                    catch(Exception ex)
                    {
                        Logger.WriteToEventLog(EventLogEntryType.Warning, 104, "ExchangeDataAccess, AutodiscoverURL error: " + ex.Message);
                    }
                    
                    if (exchangeService.Url == null)
                    {
                        this.ExchangeServerURL = GetOffice365EWSUrl(this.Username);
                        this.exchangeService.Url = new Uri(this.ExchangeServerURL);
                        this.exchangeService.CookieContainer = new CookieContainer();
                    }


Afterwhich we Login and find our exchange user that we will perform all operations under

ServicePointManager.ServerCertificateValidationCallback = (sender1, certificate, chain, errors) => true;

                string username = this.Username;
                if (this.authenticateContext.GetExchangeServerVersion().Contains("365"))
                {
                    username = this.Username.Remove(this.Username.IndexOf("@"));
                }

                NameResolutionCollection resolveNameResult = this.exchangeService.ResolveName(username, ResolveNameSearchLocation.ContactsThenDirectory, true);

                if (resolveNameResult.Count() > 0)
                {
                    roomEmailAddress = resolveNameResult[0].Mailbox.Address;
                    if (!string.IsNullOrEmpty(roomEmailAddress))
                    {
                        this.ExchangeUserEmailAddress = roomEmailAddress;
                        logMsg.AppendLine("Logged into Exchange with " + roomEmailAddress + " successfully, RetrieveRoomsList is next");
                    }
                }


We then get a SubscribeResponse and save it to a list

                    subscribeResponse = this.exchangeDataAccess.ExchangeSubscribe(syncPoint.ThirdPartyId, syncPoint.Watermark, true);


We pass the above object into a wrapper method to get all Events from the EWS

            Dictionary<PullSubscription, IEnumerable<ItemEvent>> mailboxEvents = null;

            GetEventsResults eventsResults = subscription.GetEvents();

            if (eventsResults == null || eventsResults.ItemEvents.Count() == 0) {
                return mailboxEvents;
            }

            mailboxEvents = new Dictionary<PullSubscription, IEnumerable<ItemEvent>>();
            mailboxEvents.Add(subscription, eventsResults.ItemEvents);
            return mailboxEvents;

The line that calls subscription.GetEvents() is where the exception indicated at the top is returned.  

There is another layer of complexity added on because our Exchange user has a domain name of @FOOlab.onmicrosoft.com where as all of the rooms being managed have a domain name of @LAB.FOO.COM

According to the customer this is ADFS authentication, however I really don't know much about it.

I can say however that this code base did work (got events) and then something seemed to change and the error started popping up.  Originally I thought the customer changed something but we have tested this against another Office 365 (without ADFS) and saw the same error, so now I don't know what to think.   


February 17th, 2015 11:36am

Hi Owen,

This forum is for developers discusing devloping issues about apps for Office.

Since the issue is relative to Exchange developing, I would like to move it Exchange Server Development fourm.

The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us.

Thanks for your understanding.

Regards & Fei

Free Windows Admin Tool Kit Click here and download it now
February 18th, 2015 3:47am

Your problem looks similar to mine (https://social.technet.microsoft.com/Forums/exchange/en-US/964c232d-48e3-47e9-a0e2-b8d9efe61aa7/ews-pull-notifications-stop-working-on-exchange-online).

Try to use X-AnchorMailbox header. See http://support.microsoft.com/kb/2990048/en-us and https://msdn.microsoft.com/en-us/library/office/dn458789%28v=exchg.150%29.aspx. 
February 18th, 2015 5:35am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics