本文介绍了Office 365 EWS不返回X-BackendOverrideCookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Office 365在响应标头中不返回X-BackendOverrideCookie.

Office 365 does not return the X-BackendOverrideCookie in response headers.

我在请求标头中正确设置了X-AnchorMailbox和X-PreferServerAffinity.正如MSDN中所说,这不会触发X-BackendOverrideCookie的返回.为什么会这样?

I set the X-AnchorMailbox and X-PreferServerAffinity in the request headers properly. This does not trigger X-BackendOverrideCookie to be returned, as it says in MSDN. Why is this happening?

与此同时,我在内部部署的Exchange 2016中尝试了相同的操作.在这里,我什至没有设置X-AnchorMailbox和X-PreferServerAffinity,并且在每个响应中都返回了X-BackendOverrideCookie.这也不是一件好事,因为我需要管理与拉式和推式通知组有关的亲和力,并且需要在需要时设置此cookie,并且默认情况下不必始终设置它.

Meanwhile, I tried the same thing with an on-premise Exchange 2016. Here I don't even set the X-AnchorMailbox and X-PreferServerAffinity and I get back the X-BackendOverrideCookie in each response. This is not good either, since I need to manage affinity for groups of pull and push notifications, and I need to set this cookie when I want, and not have it set always by default.

流程是这样的.我正在使用JS发送订阅请求.为此,我使用泡沫将请求包装成SOAP格式.

The flow goes like this. I am sending the subscribe request using JS. For that purpose I use lather to wrap my request into SOAP format.

该操作的外观如下:

var impersonate = ‘[email protected]’

var subscribe = {
         "m:Subscribe": {
                    "m:PullSubscriptionRequest": {
                        "t:FolderIds": {
                            "t:DistinguishedFolderId": {
                                attributes: [{
                                    'Id': this.distinguishedFolderId
                                }]
                            }
                        },
                        "t:EventTypes": [{
                            "t:EventType": "CreatedEvent"
                        }, {
                            "t:EventType": "DeletedEvent"
                        }, {
                            "t:EventType": "ModifiedEvent"
                        }],
                        "t:Timeout": "10"
                    }
                }
  };


soapHeader = {
                "t:ExchangeImpersonation": {
                   "t:ConnectingSID": {
                       't:SmtpAddress': impersonate
                   }
                }
             }

lather.up({
                body : requestName,
                headers : {
                    Authorization : lather.basicAuth(this.username, this.password),
                    'X-AnchorMailbox': impersonate,
                    'X-PreferServerAffinity': true
                },
                additionalNamespaces : [
                    'xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"',
                    'xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"',
                ],
                soapHeader : soapHeader,
                method : 'POST',
                url : ‘https://outlook.office365.com/EWS/Exchange.asmx',
            }, function(error, res, body) {
               // Process the response
            })

执行此请求后,请求就形成并发送出去.当我查看发出的原始请求时,我确认标头就位.

When this executes the request is formed and sent out. When I look at the raw request being sent out, I confirm that the headers are in place.

headers:
{ Authorization: 'Basic c29m…’, (shortened just in case)
'X-AnchorMailbox': ‘[email protected]', (fake mail)
'X-PreferServerAffinity': true,
'Content-Length': 971,
'Content-Type': 'text/xml; charset=utf-8',
host: 'outlook.office365.com' }

然后我从Office收到以下答复.

Then I get back the following response from Office.

响应的正文:(缩短ID,以防万一)

The body of the response: (shortened Ids, just in case)

<?xml version="1.0" encoding="utf-8"?><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Header><h:ServerVersionInfo MajorVersion="15" MinorVersion="1" MajorBuildNumber="693" MinorBuildNumber="12" Version="V2016_10_10" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/></s:Header><s:Body><m:SubscribeResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"><m:ResponseMessages><m:SubscribeResponseMessage ResponseClass="Success"><m:ResponseCode>NoError</m:ResponseCode><m:SubscriptionId>KQB2aTFwcjA…wucsA==</m:SubscriptionId><m:Watermark>AQAAAFQ+2wmbaZF…JAAAAAAA=</m:Watermark></m:SubscribeResponseMessage></m:ResponseMessages></m:SubscribeResponse></s:Body></s:Envelope>

响应的标头是:(ID,cookie缩短)

The headers of the response are: (shortened Ids, cookie)

{ 'cache-control': 'private',
'transfer-encoding': 'chunked',
'content-type': 'text/xml; charset=utf-8',
server: 'Microsoft-IIS/8.5',
'request-id': ‘2881ab3…1ec461’,
'x-calculatedbetarget': 'VI1PR0501MB2096.eurprd05.prod.outlook.com',
'x-backendhttpstatus': '200',
'set-cookie': [ ‘exchangecookie=d8f8…1e8; expires=Sat, 28-Oct-2017 08:41:27 GMT; path=/; HttpOnly' ],
'x-ewshandler': 'Subscribe',
'x-aspnet-version': '4.0.30319',
'x-diaginfo': 'VI1PR0501MB2096',
'x-beserver': 'VI1PR0501MB2096',
'x-powered-by': 'ASP.NET',
'x-feserver': 'VI1PR0901CA0093',
date: 'Fri, 28 Oct 2016 08:41:26 GMT' }

如您所见,我仅获得交换cookie,而没有X-BackendOverrideCookie.有什么想法吗?我在做错什么吗?

As you can see I only get the exchange cookie, and no X-BackendOverrideCookie. Any ideas on what is going on? Am I doing something wrong?

编辑2 :

我也使用EWSEditor进行了尝试.设置两个标头,并发出请求订阅请求.我得到的结果与这里相同.

I also tried this with EWSEditor. Set the two headers, and made a pull subscription request. I get the same result as here.

修改3:

以下是完整的请求

推荐答案

您的问题不包括SOAP标头,但是如果遇到与我相同的问题,那么问题在于这些标头中的RequestServerVersion参数

Your question doesn't include the SOAP headers, but if you're encountering the same problems I was, then the issue is with the RequestServerVersion parameter in those headers.

具体来说,您需要添加以下内容:

Specifically, you'll want to include something like:

<soap:Header>
    <t:RequestServerVersion Version="Exchange2013_SP1"/>
</soap:Header>

重要的部分是Exchange2013_SP1.如果没有_SP1,则Office365不会在响应中包括"X-BackendOverrideCookie" cookie.

The important part is the Exchange2013_SP1. Without the _SP1, Office365 doesn't include the 'X-BackendOverrideCookie' cookie in the response.

这篇关于Office 365 EWS不返回X-BackendOverrideCookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 02:17