我正在使用Exchange托管API并使用推送通知。我正在使用以下代码
uri uri = new Uri(" http://domain.io/mypage.aspx");
pushSubScription ps = service.subscribetepushnotifications(文件夹,uri,1,",eventType。
现在,当我从日历更改事件时,我会在domain.io/mypage.aspx上受到打击。但是现在我如何处理这种响应?请求标头的价值有限。我怎么知道该请求的哪个日历是哪个日历。
这是我的答案。使用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")
};
}
以非常基本的术语,在SubscribeToPushNotifications
调用返回PushSubscription
之后,将有一个订阅ID链接您订阅的文件夹。该文件夹的任何通知都将包含订阅ID和itemID以及通知类型,新,更改,移动等。ews通过getItem查找有关项目。