/ Połączenie / EWS API nieoczekiwanie zostało zamknięte - wymień serwisy

Połączenie z interfejsem API EWS zostało nieoczekiwanie zamknięte - wymieniono usługi internetowe

Chciałem śledzić aktywność e-mail na wspólnej skrzynce pocztowej. Moim głównym zainteresowaniem jest przenoszenie, usuwanie i modyfikacja wiadomości e-mail (zmiana kategorii) Poniżej znajduje się mój kod subskrypcji:

StreamingSubscription streamingsubscription = service.SubscribeToStreamingNotifications(
GetFolders(),
EventType.NewMail,
EventType.Modified,//if the user modified the category
EventType.Deleted,EventType.Moved);

StreamingSubscriptionConnection connection = new StreamingSubscriptionConnection(service,30);

connection.AddSubscription(streamingsubscription);
// Delegate event handlers.
connection.OnNotificationEvent +=
new StreamingSubscriptionConnection.NotificationEventDelegate(OnEvent);
connection.OnSubscriptionError +=
new StreamingSubscriptionConnection.SubscriptionErrorDelegate(OnError);
connection.OnDisconnect +=
new StreamingSubscriptionConnection.SubscriptionErrorDelegate(OnDisconnect);
connection.Open();

Oto mój moduł obsługi zdarzeń:

StreamingSubscription subscription = args.Subscription;
var events = args.Events.Select(x => x.EventType.ToString()).ToArray();
Console.WriteLine(Thread.CurrentThread.ManagedThreadId + "############Events Detected " + String.Join(",",events));



foreach (NotificationEvent notification in args.Events)
{
if (notification is ItemEvent)
{
Console.WriteLine(Thread.CurrentThread.ManagedThreadId + "Handling Item Event");
ItemEvent itemEvent;
switch (notification.EventType)
{

case EventType.NewMail:

itemEvent = (ItemEvent)notification;
Console.WriteLine(Thread.CurrentThread.ManagedThreadId + "-------------Mail Received:" + itemEvent.ItemId);
Save(itemEvent.ItemId, itemEvent.ParentFolderId.UniqueId);
break;
case EventType.Moved:

itemEvent = (ItemEvent)notification;
Console.WriteLine(Thread.CurrentThread.ManagedThreadId + "-------------Item Moved:" + itemEvent.OldItemId + " === " + itemEvent.ItemId);
Update(itemEvent.OldItemId, itemEvent.ItemId, itemEvent.ParentFolderId);

break;
case EventType.Deleted:

itemEvent = (ItemEvent)notification;
Console.WriteLine(Thread.CurrentThread.ManagedThreadId + "-------------Item deleted:" + itemEvent.ItemId);
Delete(itemEvent.ItemId);
break;
case EventType.Modified:

itemEvent = (ItemEvent)notification;
Console.WriteLine(Thread.CurrentThread.ManagedThreadId + "-------------Item Modified:" + itemEvent.ItemId);

Console.WriteLine(Thread.CurrentThread.ManagedThreadId + "-------------Item Changed Detected-----------");
Modify(itemEvent.ItemId);

break;
}




}
else
{
Console.WriteLine(Thread.CurrentThread.ManagedThreadId + "------------Ignoring Folder Event");
}

}
Console.WriteLine(Thread.CurrentThread.ManagedThreadId + "#######Done");

Na początku wszystko działa dobrze. Zauważyłem jednak, że niektóre zdarzenia nie zostały uruchomione. Na przykład, jeśli użytkownik zmieni kategorię e-mail, a następnie natychmiast ją przeniesie, nie wszystkie zdarzenia zostaną obsłużone. Obserwowałem dane wyjściowe na konsoli i nie widziałem zdarzenia „przeniesione”. Co byłoby tego przyczyną?

Odpowiedzi:

0 dla odpowiedzi № 1

Okazuje się, że problem dotyczy adresu URL EWS. Użyłem automatycznego wykrywania EWS. Przeglądając online, widziałem, że ktoś ma podobny problem. Rozwiązał to, łącząc się bezpośrednio z serwerem wymiany.

Postępowałem zgodnie z tym dokumentem, aby znaleźć mój adres URL usługi Exchange.

http://nuanceimaging.custhelp.com/app/answers/detail/a_id/13098/~/determining-the-exchange-web-services-(ews)-url-for-the-sharescan-exchange

Automatyczne wykrywanie EWS używało adresu URL wymienionego w „Protokole: Exchange RPC”. Widziałem inny adres URL wymieniony w „Protocal: Exchange HTTP”. Ręcznie ustawiłem adres URL na wersję HTTP. Problem rozwiązany!!