2017-03-01 65 views
0

我正在使用交換託管API並使用推送通知。 我正在使用下面的代碼交換api推送通知響應

Uri uri = new Uri(「http://domain.io/MyPage.aspx」); (文件夾,uri,1,「」,EventType.Created,EventType.Modified,EventType.Deleted);

現在,當我從日曆中更改事件時,我在domain.io/MyPage.aspx上遇到了問題。 但現在我怎麼處理這個迴應? 請求標頭中的值有限。 我怎麼能知道哪個日曆,這個請求來自哪個服務。

回答

1

這是我的答案。使用API​​調用更簡單。

public HttpResponseMessage ExchangeCalendar() 
    { 
     string itemId = string.Empty; 
     string subscriptionId = string.Empty; 
     string pushResponse = "OK"; 
     string RESPONSE_OK = string.Empty; 

     HttpContent requestContent = Request.Content; 
     string eventData = requestContent.ReadAsStringAsync().Result; 
     XmlDocument doc = new XmlDocument(); 
     doc.LoadXml(eventData); 

     subscriptionId = GetNodeValue(doc.GetElementsByTagName("t:SubscriptionId")); 
     itemId = GetNodeValue(doc.GetElementsByTagName("t:ItemId")); 
     calendarId = GetNodeValue(doc.GetElementsByTagName("t:FolderId")); 

     RESPONSE_OK = "<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope\"><soap:Body><SendNotificationResult xmlns=\"http://schemas.microsoft.com/exchange/services/2006/messages\"><SubscriptionStatus>" + pushResponse + "</SubscriptionStatus></SendNotificationResult></soap:Body></soap:Envelope>"; 
     return new HttpResponseMessage() 
     { 
      Content = new StringContent(RESPONSE_OK, Encoding.UTF8, "text/xml") 
     }; 
    } 
0

在非常基本的術語中,在SubscribeToPushNotifications調用返回PushSubscription之後,將會有一個訂閱ID鏈接您訂閱的文件夾。該文件夾的任何通知都將包含訂閱ID和ItemId,以及通知的類型,新建,更改,移動等。您需要維護訂閱ID到文件夾的某種映射,然後調用通過GetItem的EWS查找有問題的項目。

+0

謝謝pjneary。但我的問題是,我如何從該通知中獲取值。當日歷發生變化時,ews api會打電話給我的網址。現在在哪些變量中這些值是。我正在使用C#代碼,我也檢查request.header,但也沒有信息..請幫助 –

+0

請回復。我被卡住了。等待c#代碼 –