Office 365 EWS未返回X-BackendOverrideCookie

4

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 = ‘myroomresource@mydomain.comvar 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': ‘myroomresource@mydomain.com', (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:

这是完整的请求


这对我和其他人来说都可以正常工作,所以很可能是你的代码有问题,你需要发布你正在使用的内容。 - Glen Scales
@GlenScales,请查看我的编辑。 - eomeroff
@GlenScales,你有一个管理亲和性的工作应用程序的例子吗? - eomeroff
https://ewsstreaming.codeplex.com/SourceControl/latest#EWSStreamingNotificationSample/EWSStreamingNotificationSample/GroupInfo.cs 是其中之一。我在流通知中使用它,其中将多个用户分组到单个连接中非常重要(如果不起作用,这将是一个大问题)。如果我尝试拉取示例,我看不到返回的cookie,您是否实际上需要Pull订阅的cookie? (因为我认为AnchorMailbox足以进行路由),文档并没有提供更多的清晰度,因为所有内容都集中在流通知上。不错的问题。 - Glen Scales
@eomeroff 你好,我也遇到了Pull Subscriptions的同样问题。你解决了吗?当我尝试以下两个步骤时:i)使用先前的水印创建Pull Subscription和ii)调用GetEvents,我会在不同的运行中获得两个不同的响应。一个包含两个事件,这是预期的,另一个则为空事件。我认为这是由于“亲和性”引起的。但是,当我尝试维护亲和性时,我没有得到“X-BackendOverrideCookie” cookie。 - bala
显示剩余2条评论
1个回答

0

你的问题中没有包含SOAP头,但如果你遇到了和我一样的问题,那么问题可能出在这些头部中的RequestServerVersion参数。

具体来说,你需要包含类似于以下内容:

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

重要的部分是Exchange2013_SP1。没有 _SP1,Office365在响应中不包含 'X-BackendOverrideCookie' Cookie。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接