Office 365 EWS不会返回X-BackendOverrideCookie

问题描述 投票:3回答:1

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

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

同时,我尝试使用内部部署的Exchange 2016进行相同的操作。在这里,我甚至没有设置X-AnchorMailbox和X-PreferServerAffinity,我在每个响应中都返回了X-BackendOverrideCookie。这也不好,因为我需要管理拉动和推送通知组的亲和力,我需要在我想要的时候设置这个cookie,而不是默认设置它。

编辑1:

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

这是该操作的样子:

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
            })

当执行此请求时,将形成并发送出去。当我查看发送的原始请求时,我确认标头已到位。

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得到以下回复。

响应的主体:(缩短了ID,以防万一)

<?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)

{ '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。关于发生了什么的任何想法?难道我做错了什么?

编辑2:

我也用EWSEditor尝试过这个。设置两个标头,并发出拉取订阅请求。我得到的结果与此相同。

编辑3:

这是完整的request

office365 exchange-server exchangewebservices ews-managed-api affinity
1个回答
0
投票

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

具体来说,您需要包含以下内容:

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

重要的部分是Exchange2013_SP1。如果没有_SP1,Office365不会在响应中包含“X-BackendOverrideCookie”cookie。

© www.soinside.com 2019 - 2024. All rights reserved.