如何向EWS PUSH通知发送确定或取消订阅响应

时间:2017-03-16 12:39:04

标签: exchangewebservices

我在C#中使用exchange api Push通知。 我在Request.InputStream中的.aspx页面(C#)上收到了交换api推送通知。

现在我需要发送OK响应。但我的问题是,我必须发送此响应。我指的是哪个URL以及如何。 请帮我用C#代码。 以下是我的代码:

我在google上看到了一些示例,所以我尝试发送SOAP消息:

string oRequest = "";
            oRequest = "<?xml version=\"1.0\" encoding=\"UTF - 8\"?>";
            oRequest += "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:m=\"http://schemas.microsoft.com/exchange/services/2006/messages\" xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">";
            oRequest += "<soap:Body><m:SendNotificationResult><m:SubscriptionStatus>Ok</m:SubscriptionStatus></m:SendNotificationResult></soap:Body>";
            oRequest += "</soap:Envelope>";


HttpWebRequest req = (HttpWebRequest)WebRequest.Create("This is the URL which i provide to exchange when i create subsricption. Is this wrong, What will be the URL");
                req.Headers.Add("SOAPAction", "http://schemas.microsoft.com/exchange/services/2006/messages/SendNotification")
                req.ContentType = "text/xml; charset=\"utf-8\"";
                req.Accept = "text/xml";
                req.Method = "POST";

                //Passes the SoapRequest String to the WebService
                using (Stream stm = req.GetRequestStream())
                {
                    using (StreamWriter stmw = new StreamWriter(stm))
                    {
                        stmw.Write(oRequest);
                    }
                }
                //Gets the response
                WebResponse response = req.GetResponse();
                //Writes the Response
                Stream responseStream = response.GetResponseStream();
                StreamReader sr = new StreamReader(responseStream);
                string s = sr.ReadToEnd();

1 个答案:

答案 0 :(得分:0)

推送通知会自动发送到Web服务侦听器(订阅请求中指定的回调URL)。 当推送通知将事件发送到您的Web服务侦听器时。您可以发送您的回复(确定或取消订阅)。 您无需拨打交换网址。 你可以参考: https://msdn.microsoft.com/en-us/library/office/dn458791(v=exchg.150).aspx