EWS GetStreamingEvents。仅在超时时收到响应
EWS GetStreamingEvents. Response is received only by timeout
在我的 iOS 应用程序中,我试图从 this manual 之后的 EWS
获取流媒体事件。所以首先我订阅通知,接收订阅 ID,然后执行 GetStreamingEvents
请求。订阅过程成功,但获取流媒体事件失败。我只在超时时收到回复。是的,它确实包含所有通知,所以没有问题,但我希望在事件发生后而不是在请求时间结束时收到响应。
所以我启动了 Charles 并检查了 Mac 邮件应用程序的流量。我可以看到它在发出 GetStreamingEvents
请求后立即收到一个响应,然后每当事件按预期发生时它都会成功收到响应。所以我让我的 XML 看起来和 Mac 邮件应用程序一模一样,但仍然没有成功。
这是我的 Subscribe
xml:
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<soap:Header>
<t:RequestedServerVersion Version="Exchange2010_SP2" />
</soap:Header>
<soap:Body>
<m:Subscribe xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
<m:StreamingSubscriptionRequest SubscribeToAllFolders="true">
<t:EventTypes>
<t:EventType>CopiedEvent</t:EventType>
<t:EventType>CreatedEvent</t:EventType>
<t:EventType>DeletedEvent</t:EventType>
<t:EventType>ModifiedEvent</t:EventType>
<t:EventType>MovedEvent</t:EventType>
<t:EventType>NewMailEvent</t:EventType>
<t:EventType>FreeBusyChangedEvent</t:EventType>
</t:EventTypes>
</m:StreamingSubscriptionRequest>
</m:Subscribe>
</soap:Body>
</soap:Envelope>
这是我的 GetStreamingEvents
xml:
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<soap:Header>
<t:RequestServerVersion Version="Exchange2010_SP2" />
</soap:Header>
<soap:Body>
<m:GetStreamingEvents xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
<m:SubscriptionIds>
<t:SubscriptionId>JwBkYjVwcjA2bWIxNDY0LmV1cnByZDA2LnByb2Qub3V0bG9vay5jb20QAAAAF9r7tBXj+U+UapGUZ4XFytKbA+ad1dQIEAAAAMiCIP/mQqJOjzx9Aog45Fk=</t:SubscriptionId>
</m:SubscriptionIds>
<m:ConnectionTimeout>30</m:ConnectionTimeout>
</m:GetStreamingEvents>
</soap:Body>
</soap:Envelope>
有什么想法吗,伙计们?
更新:
这就是我建立订阅的方式:
bcstring SubscribeRequestMessage::buildSoapRequest() const
{
xml_document<> doc;
xml_node<>* decl = doc.allocate_node(node_declaration);
decl->append_attribute(doc.allocate_attribute("version", "1.0"));
decl->append_attribute(doc.allocate_attribute("encoding", "utf-8"));
doc.append_node(decl);
// Envelope
xml_node<>* envelope = doc.allocate_node(node_element, "soap:Envelope");
envelope->append_attribute(doc.allocate_attribute("xmlns:soap", "http://schemas.xmlsoap.org/soap/envelope/"));
envelope->append_attribute(doc.allocate_attribute("xmlns:t", "http://schemas.microsoft.com/exchange/services/2006/types"));
doc.append_node(envelope);
{
// Header
xml_node<>* header = doc.allocate_node(node_element, "soap:Header");
{
xml_node<>* reqServerVersion = doc.allocate_node(node_element, "t:RequestedServerVersion");
xml_attribute<>* serverVersionAttribute = doc.allocate_attribute("Version", m_requestedServerVersion.c_str());
reqServerVersion->append_attribute(serverVersionAttribute);
header->append_node(reqServerVersion);
}
envelope->append_node(header);
// Body
xml_node<>* body = doc.allocate_node(node_element, "soap:Body");
{
xml_node<>* subscribe = doc.allocate_node(node_element, "m:Subscribe");
{
subscribe->append_attribute(doc.allocate_attribute("xmlns:m", "http://schemas.microsoft.com/exchange/services/2006/messages"));
xml_node<>* streamingSubscriptionRequest = doc.allocate_node(node_element, "m:StreamingSubscriptionRequest");
{
if (m_folderIds.size() > 0)
{
xml_node<>* folderIds = doc.allocate_node(node_element, "t:FolderIds");
{
for (const bcstring& folderId : m_folderIds)
{
xml_node<>* folderIdNode = doc.allocate_node(node_element, "t:FolderId");
folderIdNode->append_attribute(doc.allocate_attribute("Id", folderId.c_str()));
folderIds->append_node(folderIdNode);
}
}
streamingSubscriptionRequest->append_node(folderIds);
}
else
{
xml_attribute<>* subscribeToAll = doc.allocate_attribute("SubscribeToAllFolders", "true");
streamingSubscriptionRequest->append_attribute(subscribeToAll);
}
xml_node<>* eventTypes = doc.allocate_node(node_element, "t:EventTypes");
{
for (const bcstring& eventType : m_eventTypes)
{
xml_node<>* eventTypeNode = doc.allocate_node(node_element, "t:EventType");
xml_node<>* eventTypeValueNode = doc.allocate_node(node_data, "", eventType.c_str());
eventTypeNode->append_node(eventTypeValueNode);
eventTypes->append_node(eventTypeNode);
}
}
streamingSubscriptionRequest->append_node(eventTypes);
}
subscribe->append_node(streamingSubscriptionRequest);
}
body->append_node(subscribe);
}
envelope->append_node(body);
}
bcstring retVal;
print(std::back_inserter(retVal), doc, print_no_indenting);
return retVal;
}
这就是我构建 get streaming 的方式 xml:
bcstring GetStreamingEventsRequest::buildSoapRequest() const
{
xml_document<> doc;
xml_node<>* decl = doc.allocate_node(node_declaration);
decl->append_attribute(doc.allocate_attribute("version", "1.0"));
decl->append_attribute(doc.allocate_attribute("encoding", "utf-8"));
doc.append_node(decl);
// Envelope
xml_node<>* envelope = doc.allocate_node(node_element, "soap:Envelope");
envelope->append_attribute(doc.allocate_attribute("xmlns:soap", "http://schemas.xmlsoap.org/soap/envelope/"));
envelope->append_attribute(doc.allocate_attribute("xmlns:t", "http://schemas.microsoft.com/exchange/services/2006/types"));
doc.append_node(envelope);
{
// Header
xml_node<>* header = doc.allocate_node(node_element, "soap:Header");
{
xml_node<>* reqServerVersion = doc.allocate_node(node_element, "t:RequestServerVersion");
xml_attribute<>* serverVersionAttribute = doc.allocate_attribute("Version", m_requestedServerVersion.c_str());
reqServerVersion->append_attribute(serverVersionAttribute);
header->append_node(reqServerVersion);
}
envelope->append_node(header);
// Body
xml_node<>* body = doc.allocate_node(node_element, "soap:Body");
{
xml_node<>* getStreamingEvents = doc.allocate_node(node_element, "m:GetStreamingEvents");
{
getStreamingEvents->append_attribute(doc.allocate_attribute("xmlns:m", "http://schemas.microsoft.com/exchange/services/2006/messages"));
xml_node<>* subscriptionIds = doc.allocate_node(node_element, "m:SubscriptionIds");
{
for (const bcstring& subscriptionId : m_subscriptionIds)
{
xml_node<>* subscriptionIdNode = doc.allocate_node(node_element, "t:SubscriptionId");
xml_node<>* subscriptionIdValue = doc.allocate_node(node_data, "", subscriptionId.c_str());
subscriptionIdNode->append_node(subscriptionIdValue);
subscriptionIds->append_node(subscriptionIdNode);
}
}
getStreamingEvents->append_node(subscriptionIds);
xml_node<>* connectionTimeout = doc.allocate_node(node_element, "m:ConnectionTimeout");
bcstring connectionTimeoutString = std::to_string(m_connectionTimeout);
xml_node<>* connectionTimeoutValue = doc.allocate_node(node_data, "", connectionTimeoutString.c_str());
connectionTimeout->append_node(connectionTimeoutValue);
getStreamingEvents->append_node(connectionTimeout);
}
body->append_node(getStreamingEvents);
}
envelope->append_node(body);
}
bcstring retVal;
print(std::back_inserter(retVal), doc, print_no_indenting);
return retVal;
}
更新:
这是我通过 Charles 看到的 Mac 邮件应用程序的 XML:
订阅:
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<soap:Header>
<t:RequestServerVersion Version="Exchange2010_SP2" />
</soap:Header>
<soap:Body>
<m:Subscribe xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
<m:StreamingSubscriptionRequest SubscribeToAllFolders="true">
<t:EventTypes>
<t:EventType>CopiedEvent</t:EventType>
<t:EventType>CreatedEvent</t:EventType>
<t:EventType>DeletedEvent</t:EventType>
<t:EventType>ModifiedEvent</t:EventType>
<t:EventType>MovedEvent</t:EventType>
<t:EventType>NewMailEvent</t:EventType>
<t:EventType>FreeBusyChangedEvent</t:EventType>
</t:EventTypes>
</m:StreamingSubscriptionRequest>
</m:Subscribe>
</soap:Body>
</soap:Envelope>
和流媒体:
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<soap:Header>
<t:RequestServerVersion Version="Exchange2010_SP2" />
</soap:Header>
<soap:Body>
<m:GetStreamingEvents xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
<m:SubscriptionIds>
<t:SubscriptionId>JwBkYjVwcjA2bWIxNDY0LmV1cnByZDA2LnByb2Qub3V0bG9vay5jb20QAAAADv7qpS0xbU6V0mCxt2SvFHYOYoCq1dQIEAAAAMiCIP/mQqJOjzx9Aog45Fk=</t:SubscriptionId>
</m:SubscriptionIds>
<m:ConnectionTimeout>30</m:ConnectionTimeout>
</m:GetStreamingEvents>
</soap:Body>
</soap:Envelope>
这是 EWS 在超时时到达的响应,其中包含有关新邮件的通知:
<Envelope
xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<soap11:Header
xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/">
<ServerVersionInfo
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" MajorVersion="15" MinorVersion="1" MajorBuildNumber="1282" MinorBuildNumber="22" Version="V2017_04_14"
xmlns="http://schemas.microsoft.com/exchange/services/2006/types" />
</soap11:Header>
<soap11:Body
xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/">
<m:GetStreamingEventsResponse
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"
xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
<m:ResponseMessages>
<m:GetStreamingEventsResponseMessage ResponseClass="Success">
<m:ResponseCode>NoError</m:ResponseCode>
<m:ConnectionStatus>OK</m:ConnectionStatus>
</m:GetStreamingEventsResponseMessage>
</m:ResponseMessages>
</m:GetStreamingEventsResponse>
</soap11:Body>
</Envelope>
<Envelope
xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<soap11:Header
xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/">
<ServerVersionInfo
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" MajorVersion="15" MinorVersion="1" MajorBuildNumber="1282" MinorBuildNumber="22" Version="V2017_04_14"
xmlns="http://schemas.microsoft.com/exchange/services/2006/types" />
</soap11:Header>
<soap11:Body
xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/">
<m:GetStreamingEventsResponse
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"
xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
<m:ResponseMessages>
<m:GetStreamingEventsResponseMessage ResponseClass="Success">
<m:ResponseCode>NoError</m:ResponseCode>
<m:Notifications>
<m:Notification>
<t:SubscriptionId>JwBkYjVwcjA2bWIxNDY0LmV1cnByZDA2LnByb2Qub3V0bG9vay5jb20QAAAA4mbQZqHZf0aA35Z5r1UEvPZtJfmw1dQIEAAAAMiCIP/mQqJOjzx9Aog45Fk=</t:SubscriptionId>
<t:CreatedEvent>
<t:TimeStamp>2017-07-28T12:06:04Z</t:TimeStamp>
<t:ItemId Id="AAMkAGZmMjA4MmM4LTQyZTYtNGVhMi04ZjNjLTdkMDI4ODM4ZTQ1OQBGAAAAAADKa2Su6/EXRrsmOefDSCL3BwBEITO0krAyRbRmLsC3JNeGAAAAAAEMAABEITO0krAyRbRmLsC3JNeGAAAdPAOsAAA=" ChangeKey="CQAAAA==" />
<t:ParentFolderId Id="AAMkAGZmMjA4MmM4LTQyZTYtNGVhMi04ZjNjLTdkMDI4ODM4ZTQ1OQAuAAAAAADKa2Su6/EXRrsmOefDSCL3AQBEITO0krAyRbRmLsC3JNeGAAAAAAEMAAA=" ChangeKey="AQAAAA==" />
</t:CreatedEvent>
<t:NewMailEvent>
<t:TimeStamp>2017-07-28T12:06:04Z</t:TimeStamp>
<t:ItemId Id="AAMkAGZmMjA4MmM4LTQyZTYtNGVhMi04ZjNjLTdkMDI4ODM4ZTQ1OQBGAAAAAADKa2Su6/EXRrsmOefDSCL3BwBEITO0krAyRbRmLsC3JNeGAAAAAAEMAABEITO0krAyRbRmLsC3JNeGAAAdPAOsAAA=" ChangeKey="CQAAAA==" />
<t:ParentFolderId Id="AAMkAGZmMjA4MmM4LTQyZTYtNGVhMi04ZjNjLTdkMDI4ODM4ZTQ1OQAuAAAAAADKa2Su6/EXRrsmOefDSCL3AQBEITO0krAyRbRmLsC3JNeGAAAAAAEMAAA=" ChangeKey="AQAAAA==" />
</t:NewMailEvent>
<t:ModifiedEvent>
<t:TimeStamp>2017-07-28T12:06:04Z</t:TimeStamp>
<t:FolderId Id="AAMkAGZmMjA4MmM4LTQyZTYtNGVhMi04ZjNjLTdkMDI4ODM4ZTQ1OQAuAAAAAADKa2Su6/EXRrsmOefDSCL3AQBEITO0krAyRbRmLsC3JNeGAAAAAAEMAAA=" ChangeKey="AQAAAA==" />
<t:ParentFolderId Id="AAMkAGZmMjA4MmM4LTQyZTYtNGVhMi04ZjNjLTdkMDI4ODM4ZTQ1OQAuAAAAAADKa2Su6/EXRrsmOefDSCL3AQBEITO0krAyRbRmLsC3JNeGAAAAAAEIAAA=" ChangeKey="AQAAAA==" />
<t:UnreadCount>1</t:UnreadCount>
</t:ModifiedEvent>
</m:Notification>
</m:Notifications>
</m:GetStreamingEventsResponseMessage>
</m:ResponseMessages>
</m:GetStreamingEventsResponse>
</soap11:Body>
</Envelope>
<Envelope
xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<soap11:Header
xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/">
<ServerVersionInfo
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" MajorVersion="15" MinorVersion="1" MajorBuildNumber="1282" MinorBuildNumber="22" Version="V2017_04_14"
xmlns="http://schemas.microsoft.com/exchange/services/2006/types" />
</soap11:Header>
<soap11:Body
xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/">
<m:GetStreamingEventsResponse
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"
xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
<m:ResponseMessages>
<m:GetStreamingEventsResponseMessage ResponseClass="Success">
<m:ResponseCode>NoError</m:ResponseCode>
<m:ConnectionStatus>OK</m:ConnectionStatus>
</m:GetStreamingEventsResponseMessage>
</m:ResponseMessages>
</m:GetStreamingEventsResponse>
</soap11:Body>
</Envelope>
<Envelope
xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<soap11:Header
xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/">
<ServerVersionInfo
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" MajorVersion="15" MinorVersion="1" MajorBuildNumber="1282" MinorBuildNumber="22" Version="V2017_04_14"
xmlns="http://schemas.microsoft.com/exchange/services/2006/types" />
</soap11:Header>
<soap11:Body
xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/">
<m:GetStreamingEventsResponse
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"
xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
<m:ResponseMessages>
<m:GetStreamingEventsResponseMessage ResponseClass="Success">
<m:ResponseCode>NoError</m:ResponseCode>
<m:ConnectionStatus>OK</m:ConnectionStatus>
</m:GetStreamingEventsResponseMessage>
</m:ResponseMessages>
</m:GetStreamingEventsResponse>
</soap11:Body>
</Envelope>
<Envelope
xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<soap11:Header
xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/">
<ServerVersionInfo
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" MajorVersion="15" MinorVersion="1" MajorBuildNumber="1282" MinorBuildNumber="22" Version="V2017_04_14"
xmlns="http://schemas.microsoft.com/exchange/services/2006/types" />
</soap11:Header>
<soap11:Body
xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/">
<m:GetStreamingEventsResponse
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"
xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
<m:ResponseMessages>
<m:GetStreamingEventsResponseMessage ResponseClass="Success">
<m:ResponseCode>NoError</m:ResponseCode>
<m:Notifications>
<m:Notification>
<t:SubscriptionId>JwBkYjVwcjA2bWIxNDY0LmV1cnByZDA2LnByb2Qub3V0bG9vay5jb20QAAAA4mbQZqHZf0aA35Z5r1UEvPZtJfmw1dQIEAAAAMiCIP/mQqJOjzx9Aog45Fk=</t:SubscriptionId>
<t:ModifiedEvent>
<t:TimeStamp>2017-07-28T12:07:39Z</t:TimeStamp>
<t:ItemId Id="AAMkAGZmMjA4MmM4LTQyZTYtNGVhMi04ZjNjLTdkMDI4ODM4ZTQ1OQBGAAAAAADKa2Su6/EXRrsmOefDSCL3BwBEITO0krAyRbRmLsC3JNeGAAAAAAEMAABEITO0krAyRbRmLsC3JNeGAAAdPAOsAAA=" ChangeKey="CQAAAA==" />
<t:ParentFolderId Id="AAMkAGZmMjA4MmM4LTQyZTYtNGVhMi04ZjNjLTdkMDI4ODM4ZTQ1OQAuAAAAAADKa2Su6/EXRrsmOefDSCL3AQBEITO0krAyRbRmLsC3JNeGAAAAAAEMAAA=" ChangeKey="AQAAAA==" />
</t:ModifiedEvent>
<t:ModifiedEvent>
<t:TimeStamp>2017-07-28T12:07:39Z</t:TimeStamp>
<t:FolderId Id="AAMkAGZmMjA4MmM4LTQyZTYtNGVhMi04ZjNjLTdkMDI4ODM4ZTQ1OQAuAAAAAADKa2Su6/EXRrsmOefDSCL3AQBEITO0krAyRbRmLsC3JNeGAAAAAAEMAAA=" ChangeKey="AQAAAA==" />
<t:ParentFolderId Id="AAMkAGZmMjA4MmM4LTQyZTYtNGVhMi04ZjNjLTdkMDI4ODM4ZTQ1OQAuAAAAAADKa2Su6/EXRrsmOefDSCL3AQBEITO0krAyRbRmLsC3JNeGAAAAAAEIAAA=" ChangeKey="AQAAAA==" />
<t:UnreadCount>0</t:UnreadCount>
</t:ModifiedEvent>
</m:Notification>
</m:Notifications>
</m:GetStreamingEventsResponseMessage>
</m:ResponseMessages>
</m:GetStreamingEventsResponse>
</soap11:Body>
</Envelope>
<Envelope
xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<soap11:Header
xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/">
<ServerVersionInfo
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" MajorVersion="15" MinorVersion="1" MajorBuildNumber="1282" MinorBuildNumber="22" Version="V2017_04_14"
xmlns="http://schemas.microsoft.com/exchange/services/2006/types" />
</soap11:Header>
<soap11:Body
xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/">
<m:GetStreamingEventsResponse
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"
xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
<m:ResponseMessages>
<m:GetStreamingEventsResponseMessage ResponseClass="Success">
<m:ResponseCode>NoError</m:ResponseCode>
<m:ConnectionStatus>Closed</m:ConnectionStatus>
</m:GetStreamingEventsResponseMessage>
</m:ResponseMessages>
</m:GetStreamingEventsResponse>
</soap11:Body>
</Envelope>
这个问题我也运行遇到过一次,不知道你是不是也一样。我在使用分块 t运行sfer 编码的 HTTP 上使用 EWS,并且也仅在超时时收到响应。事实证明,终止 0 块仅在超时时发送,而不是在每次响应后发送,因此我一直在等待更多数据直到超时。
请注意,超时时间短并不是太糟糕,因为您可能希望在单个 GetEvents 请求中使用多个订阅,并且您无法在 运行 GetEvents 请求中添加或删除订阅。
"GetStreamingEvents" 回复确实 流式传输。
这意味着 http 连接保持打开状态,并且通过它发送通知比标准 request/response 机制更连续。这类似于流式传输视频的工作方式。您不会对整个视频执行单个请求。相反,您会在发送视频时从视频中读取流数据,并进行相应处理。
您需要以类似的方式处理对 "GetStreamingEvents" 的回复。
问题中提供的详细信息并未显示您如何处理响应,但我猜您使用的是 API,它只是获取 URL 和 return 是一个回应。这对于像 "StreamingSubscriptionRequest" 这样的标准请求非常有用,但它不适用于流式响应。
仅获取 url 的 API 不会 return 直到收到完整响应 and/or 连接关闭。这就是为什么在超时到期之前您似乎没有收到流媒体事件的原因。
事实上,您正在 接收这些事件,只是没有在它们传入时读取和处理它们。
为此,您需要使用 API 允许您连接到 HTTP 服务器并在数据到达时从该连接读取。对于 iOS,这就像在 NSURLConnection 上实现 [connection didReceiveData:] 委托方法一样简单。据推测,有一些类似的更高级别的机制可以在您的环境中使用。
在我的 iOS 应用程序中,我试图从 this manual 之后的 EWS
获取流媒体事件。所以首先我订阅通知,接收订阅 ID,然后执行 GetStreamingEvents
请求。订阅过程成功,但获取流媒体事件失败。我只在超时时收到回复。是的,它确实包含所有通知,所以没有问题,但我希望在事件发生后而不是在请求时间结束时收到响应。
所以我启动了 Charles 并检查了 Mac 邮件应用程序的流量。我可以看到它在发出 GetStreamingEvents
请求后立即收到一个响应,然后每当事件按预期发生时它都会成功收到响应。所以我让我的 XML 看起来和 Mac 邮件应用程序一模一样,但仍然没有成功。
这是我的 Subscribe
xml:
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<soap:Header>
<t:RequestedServerVersion Version="Exchange2010_SP2" />
</soap:Header>
<soap:Body>
<m:Subscribe xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
<m:StreamingSubscriptionRequest SubscribeToAllFolders="true">
<t:EventTypes>
<t:EventType>CopiedEvent</t:EventType>
<t:EventType>CreatedEvent</t:EventType>
<t:EventType>DeletedEvent</t:EventType>
<t:EventType>ModifiedEvent</t:EventType>
<t:EventType>MovedEvent</t:EventType>
<t:EventType>NewMailEvent</t:EventType>
<t:EventType>FreeBusyChangedEvent</t:EventType>
</t:EventTypes>
</m:StreamingSubscriptionRequest>
</m:Subscribe>
</soap:Body>
</soap:Envelope>
这是我的 GetStreamingEvents
xml:
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<soap:Header>
<t:RequestServerVersion Version="Exchange2010_SP2" />
</soap:Header>
<soap:Body>
<m:GetStreamingEvents xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
<m:SubscriptionIds>
<t:SubscriptionId>JwBkYjVwcjA2bWIxNDY0LmV1cnByZDA2LnByb2Qub3V0bG9vay5jb20QAAAAF9r7tBXj+U+UapGUZ4XFytKbA+ad1dQIEAAAAMiCIP/mQqJOjzx9Aog45Fk=</t:SubscriptionId>
</m:SubscriptionIds>
<m:ConnectionTimeout>30</m:ConnectionTimeout>
</m:GetStreamingEvents>
</soap:Body>
</soap:Envelope>
有什么想法吗,伙计们?
更新:
这就是我建立订阅的方式:
bcstring SubscribeRequestMessage::buildSoapRequest() const
{
xml_document<> doc;
xml_node<>* decl = doc.allocate_node(node_declaration);
decl->append_attribute(doc.allocate_attribute("version", "1.0"));
decl->append_attribute(doc.allocate_attribute("encoding", "utf-8"));
doc.append_node(decl);
// Envelope
xml_node<>* envelope = doc.allocate_node(node_element, "soap:Envelope");
envelope->append_attribute(doc.allocate_attribute("xmlns:soap", "http://schemas.xmlsoap.org/soap/envelope/"));
envelope->append_attribute(doc.allocate_attribute("xmlns:t", "http://schemas.microsoft.com/exchange/services/2006/types"));
doc.append_node(envelope);
{
// Header
xml_node<>* header = doc.allocate_node(node_element, "soap:Header");
{
xml_node<>* reqServerVersion = doc.allocate_node(node_element, "t:RequestedServerVersion");
xml_attribute<>* serverVersionAttribute = doc.allocate_attribute("Version", m_requestedServerVersion.c_str());
reqServerVersion->append_attribute(serverVersionAttribute);
header->append_node(reqServerVersion);
}
envelope->append_node(header);
// Body
xml_node<>* body = doc.allocate_node(node_element, "soap:Body");
{
xml_node<>* subscribe = doc.allocate_node(node_element, "m:Subscribe");
{
subscribe->append_attribute(doc.allocate_attribute("xmlns:m", "http://schemas.microsoft.com/exchange/services/2006/messages"));
xml_node<>* streamingSubscriptionRequest = doc.allocate_node(node_element, "m:StreamingSubscriptionRequest");
{
if (m_folderIds.size() > 0)
{
xml_node<>* folderIds = doc.allocate_node(node_element, "t:FolderIds");
{
for (const bcstring& folderId : m_folderIds)
{
xml_node<>* folderIdNode = doc.allocate_node(node_element, "t:FolderId");
folderIdNode->append_attribute(doc.allocate_attribute("Id", folderId.c_str()));
folderIds->append_node(folderIdNode);
}
}
streamingSubscriptionRequest->append_node(folderIds);
}
else
{
xml_attribute<>* subscribeToAll = doc.allocate_attribute("SubscribeToAllFolders", "true");
streamingSubscriptionRequest->append_attribute(subscribeToAll);
}
xml_node<>* eventTypes = doc.allocate_node(node_element, "t:EventTypes");
{
for (const bcstring& eventType : m_eventTypes)
{
xml_node<>* eventTypeNode = doc.allocate_node(node_element, "t:EventType");
xml_node<>* eventTypeValueNode = doc.allocate_node(node_data, "", eventType.c_str());
eventTypeNode->append_node(eventTypeValueNode);
eventTypes->append_node(eventTypeNode);
}
}
streamingSubscriptionRequest->append_node(eventTypes);
}
subscribe->append_node(streamingSubscriptionRequest);
}
body->append_node(subscribe);
}
envelope->append_node(body);
}
bcstring retVal;
print(std::back_inserter(retVal), doc, print_no_indenting);
return retVal;
}
这就是我构建 get streaming 的方式 xml:
bcstring GetStreamingEventsRequest::buildSoapRequest() const
{
xml_document<> doc;
xml_node<>* decl = doc.allocate_node(node_declaration);
decl->append_attribute(doc.allocate_attribute("version", "1.0"));
decl->append_attribute(doc.allocate_attribute("encoding", "utf-8"));
doc.append_node(decl);
// Envelope
xml_node<>* envelope = doc.allocate_node(node_element, "soap:Envelope");
envelope->append_attribute(doc.allocate_attribute("xmlns:soap", "http://schemas.xmlsoap.org/soap/envelope/"));
envelope->append_attribute(doc.allocate_attribute("xmlns:t", "http://schemas.microsoft.com/exchange/services/2006/types"));
doc.append_node(envelope);
{
// Header
xml_node<>* header = doc.allocate_node(node_element, "soap:Header");
{
xml_node<>* reqServerVersion = doc.allocate_node(node_element, "t:RequestServerVersion");
xml_attribute<>* serverVersionAttribute = doc.allocate_attribute("Version", m_requestedServerVersion.c_str());
reqServerVersion->append_attribute(serverVersionAttribute);
header->append_node(reqServerVersion);
}
envelope->append_node(header);
// Body
xml_node<>* body = doc.allocate_node(node_element, "soap:Body");
{
xml_node<>* getStreamingEvents = doc.allocate_node(node_element, "m:GetStreamingEvents");
{
getStreamingEvents->append_attribute(doc.allocate_attribute("xmlns:m", "http://schemas.microsoft.com/exchange/services/2006/messages"));
xml_node<>* subscriptionIds = doc.allocate_node(node_element, "m:SubscriptionIds");
{
for (const bcstring& subscriptionId : m_subscriptionIds)
{
xml_node<>* subscriptionIdNode = doc.allocate_node(node_element, "t:SubscriptionId");
xml_node<>* subscriptionIdValue = doc.allocate_node(node_data, "", subscriptionId.c_str());
subscriptionIdNode->append_node(subscriptionIdValue);
subscriptionIds->append_node(subscriptionIdNode);
}
}
getStreamingEvents->append_node(subscriptionIds);
xml_node<>* connectionTimeout = doc.allocate_node(node_element, "m:ConnectionTimeout");
bcstring connectionTimeoutString = std::to_string(m_connectionTimeout);
xml_node<>* connectionTimeoutValue = doc.allocate_node(node_data, "", connectionTimeoutString.c_str());
connectionTimeout->append_node(connectionTimeoutValue);
getStreamingEvents->append_node(connectionTimeout);
}
body->append_node(getStreamingEvents);
}
envelope->append_node(body);
}
bcstring retVal;
print(std::back_inserter(retVal), doc, print_no_indenting);
return retVal;
}
更新:
这是我通过 Charles 看到的 Mac 邮件应用程序的 XML: 订阅:
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<soap:Header>
<t:RequestServerVersion Version="Exchange2010_SP2" />
</soap:Header>
<soap:Body>
<m:Subscribe xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
<m:StreamingSubscriptionRequest SubscribeToAllFolders="true">
<t:EventTypes>
<t:EventType>CopiedEvent</t:EventType>
<t:EventType>CreatedEvent</t:EventType>
<t:EventType>DeletedEvent</t:EventType>
<t:EventType>ModifiedEvent</t:EventType>
<t:EventType>MovedEvent</t:EventType>
<t:EventType>NewMailEvent</t:EventType>
<t:EventType>FreeBusyChangedEvent</t:EventType>
</t:EventTypes>
</m:StreamingSubscriptionRequest>
</m:Subscribe>
</soap:Body>
</soap:Envelope>
和流媒体:
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<soap:Header>
<t:RequestServerVersion Version="Exchange2010_SP2" />
</soap:Header>
<soap:Body>
<m:GetStreamingEvents xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
<m:SubscriptionIds>
<t:SubscriptionId>JwBkYjVwcjA2bWIxNDY0LmV1cnByZDA2LnByb2Qub3V0bG9vay5jb20QAAAADv7qpS0xbU6V0mCxt2SvFHYOYoCq1dQIEAAAAMiCIP/mQqJOjzx9Aog45Fk=</t:SubscriptionId>
</m:SubscriptionIds>
<m:ConnectionTimeout>30</m:ConnectionTimeout>
</m:GetStreamingEvents>
</soap:Body>
</soap:Envelope>
这是 EWS 在超时时到达的响应,其中包含有关新邮件的通知:
<Envelope
xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<soap11:Header
xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/">
<ServerVersionInfo
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" MajorVersion="15" MinorVersion="1" MajorBuildNumber="1282" MinorBuildNumber="22" Version="V2017_04_14"
xmlns="http://schemas.microsoft.com/exchange/services/2006/types" />
</soap11:Header>
<soap11:Body
xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/">
<m:GetStreamingEventsResponse
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"
xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
<m:ResponseMessages>
<m:GetStreamingEventsResponseMessage ResponseClass="Success">
<m:ResponseCode>NoError</m:ResponseCode>
<m:ConnectionStatus>OK</m:ConnectionStatus>
</m:GetStreamingEventsResponseMessage>
</m:ResponseMessages>
</m:GetStreamingEventsResponse>
</soap11:Body>
</Envelope>
<Envelope
xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<soap11:Header
xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/">
<ServerVersionInfo
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" MajorVersion="15" MinorVersion="1" MajorBuildNumber="1282" MinorBuildNumber="22" Version="V2017_04_14"
xmlns="http://schemas.microsoft.com/exchange/services/2006/types" />
</soap11:Header>
<soap11:Body
xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/">
<m:GetStreamingEventsResponse
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"
xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
<m:ResponseMessages>
<m:GetStreamingEventsResponseMessage ResponseClass="Success">
<m:ResponseCode>NoError</m:ResponseCode>
<m:Notifications>
<m:Notification>
<t:SubscriptionId>JwBkYjVwcjA2bWIxNDY0LmV1cnByZDA2LnByb2Qub3V0bG9vay5jb20QAAAA4mbQZqHZf0aA35Z5r1UEvPZtJfmw1dQIEAAAAMiCIP/mQqJOjzx9Aog45Fk=</t:SubscriptionId>
<t:CreatedEvent>
<t:TimeStamp>2017-07-28T12:06:04Z</t:TimeStamp>
<t:ItemId Id="AAMkAGZmMjA4MmM4LTQyZTYtNGVhMi04ZjNjLTdkMDI4ODM4ZTQ1OQBGAAAAAADKa2Su6/EXRrsmOefDSCL3BwBEITO0krAyRbRmLsC3JNeGAAAAAAEMAABEITO0krAyRbRmLsC3JNeGAAAdPAOsAAA=" ChangeKey="CQAAAA==" />
<t:ParentFolderId Id="AAMkAGZmMjA4MmM4LTQyZTYtNGVhMi04ZjNjLTdkMDI4ODM4ZTQ1OQAuAAAAAADKa2Su6/EXRrsmOefDSCL3AQBEITO0krAyRbRmLsC3JNeGAAAAAAEMAAA=" ChangeKey="AQAAAA==" />
</t:CreatedEvent>
<t:NewMailEvent>
<t:TimeStamp>2017-07-28T12:06:04Z</t:TimeStamp>
<t:ItemId Id="AAMkAGZmMjA4MmM4LTQyZTYtNGVhMi04ZjNjLTdkMDI4ODM4ZTQ1OQBGAAAAAADKa2Su6/EXRrsmOefDSCL3BwBEITO0krAyRbRmLsC3JNeGAAAAAAEMAABEITO0krAyRbRmLsC3JNeGAAAdPAOsAAA=" ChangeKey="CQAAAA==" />
<t:ParentFolderId Id="AAMkAGZmMjA4MmM4LTQyZTYtNGVhMi04ZjNjLTdkMDI4ODM4ZTQ1OQAuAAAAAADKa2Su6/EXRrsmOefDSCL3AQBEITO0krAyRbRmLsC3JNeGAAAAAAEMAAA=" ChangeKey="AQAAAA==" />
</t:NewMailEvent>
<t:ModifiedEvent>
<t:TimeStamp>2017-07-28T12:06:04Z</t:TimeStamp>
<t:FolderId Id="AAMkAGZmMjA4MmM4LTQyZTYtNGVhMi04ZjNjLTdkMDI4ODM4ZTQ1OQAuAAAAAADKa2Su6/EXRrsmOefDSCL3AQBEITO0krAyRbRmLsC3JNeGAAAAAAEMAAA=" ChangeKey="AQAAAA==" />
<t:ParentFolderId Id="AAMkAGZmMjA4MmM4LTQyZTYtNGVhMi04ZjNjLTdkMDI4ODM4ZTQ1OQAuAAAAAADKa2Su6/EXRrsmOefDSCL3AQBEITO0krAyRbRmLsC3JNeGAAAAAAEIAAA=" ChangeKey="AQAAAA==" />
<t:UnreadCount>1</t:UnreadCount>
</t:ModifiedEvent>
</m:Notification>
</m:Notifications>
</m:GetStreamingEventsResponseMessage>
</m:ResponseMessages>
</m:GetStreamingEventsResponse>
</soap11:Body>
</Envelope>
<Envelope
xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<soap11:Header
xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/">
<ServerVersionInfo
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" MajorVersion="15" MinorVersion="1" MajorBuildNumber="1282" MinorBuildNumber="22" Version="V2017_04_14"
xmlns="http://schemas.microsoft.com/exchange/services/2006/types" />
</soap11:Header>
<soap11:Body
xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/">
<m:GetStreamingEventsResponse
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"
xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
<m:ResponseMessages>
<m:GetStreamingEventsResponseMessage ResponseClass="Success">
<m:ResponseCode>NoError</m:ResponseCode>
<m:ConnectionStatus>OK</m:ConnectionStatus>
</m:GetStreamingEventsResponseMessage>
</m:ResponseMessages>
</m:GetStreamingEventsResponse>
</soap11:Body>
</Envelope>
<Envelope
xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<soap11:Header
xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/">
<ServerVersionInfo
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" MajorVersion="15" MinorVersion="1" MajorBuildNumber="1282" MinorBuildNumber="22" Version="V2017_04_14"
xmlns="http://schemas.microsoft.com/exchange/services/2006/types" />
</soap11:Header>
<soap11:Body
xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/">
<m:GetStreamingEventsResponse
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"
xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
<m:ResponseMessages>
<m:GetStreamingEventsResponseMessage ResponseClass="Success">
<m:ResponseCode>NoError</m:ResponseCode>
<m:ConnectionStatus>OK</m:ConnectionStatus>
</m:GetStreamingEventsResponseMessage>
</m:ResponseMessages>
</m:GetStreamingEventsResponse>
</soap11:Body>
</Envelope>
<Envelope
xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<soap11:Header
xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/">
<ServerVersionInfo
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" MajorVersion="15" MinorVersion="1" MajorBuildNumber="1282" MinorBuildNumber="22" Version="V2017_04_14"
xmlns="http://schemas.microsoft.com/exchange/services/2006/types" />
</soap11:Header>
<soap11:Body
xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/">
<m:GetStreamingEventsResponse
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"
xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
<m:ResponseMessages>
<m:GetStreamingEventsResponseMessage ResponseClass="Success">
<m:ResponseCode>NoError</m:ResponseCode>
<m:Notifications>
<m:Notification>
<t:SubscriptionId>JwBkYjVwcjA2bWIxNDY0LmV1cnByZDA2LnByb2Qub3V0bG9vay5jb20QAAAA4mbQZqHZf0aA35Z5r1UEvPZtJfmw1dQIEAAAAMiCIP/mQqJOjzx9Aog45Fk=</t:SubscriptionId>
<t:ModifiedEvent>
<t:TimeStamp>2017-07-28T12:07:39Z</t:TimeStamp>
<t:ItemId Id="AAMkAGZmMjA4MmM4LTQyZTYtNGVhMi04ZjNjLTdkMDI4ODM4ZTQ1OQBGAAAAAADKa2Su6/EXRrsmOefDSCL3BwBEITO0krAyRbRmLsC3JNeGAAAAAAEMAABEITO0krAyRbRmLsC3JNeGAAAdPAOsAAA=" ChangeKey="CQAAAA==" />
<t:ParentFolderId Id="AAMkAGZmMjA4MmM4LTQyZTYtNGVhMi04ZjNjLTdkMDI4ODM4ZTQ1OQAuAAAAAADKa2Su6/EXRrsmOefDSCL3AQBEITO0krAyRbRmLsC3JNeGAAAAAAEMAAA=" ChangeKey="AQAAAA==" />
</t:ModifiedEvent>
<t:ModifiedEvent>
<t:TimeStamp>2017-07-28T12:07:39Z</t:TimeStamp>
<t:FolderId Id="AAMkAGZmMjA4MmM4LTQyZTYtNGVhMi04ZjNjLTdkMDI4ODM4ZTQ1OQAuAAAAAADKa2Su6/EXRrsmOefDSCL3AQBEITO0krAyRbRmLsC3JNeGAAAAAAEMAAA=" ChangeKey="AQAAAA==" />
<t:ParentFolderId Id="AAMkAGZmMjA4MmM4LTQyZTYtNGVhMi04ZjNjLTdkMDI4ODM4ZTQ1OQAuAAAAAADKa2Su6/EXRrsmOefDSCL3AQBEITO0krAyRbRmLsC3JNeGAAAAAAEIAAA=" ChangeKey="AQAAAA==" />
<t:UnreadCount>0</t:UnreadCount>
</t:ModifiedEvent>
</m:Notification>
</m:Notifications>
</m:GetStreamingEventsResponseMessage>
</m:ResponseMessages>
</m:GetStreamingEventsResponse>
</soap11:Body>
</Envelope>
<Envelope
xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<soap11:Header
xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/">
<ServerVersionInfo
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" MajorVersion="15" MinorVersion="1" MajorBuildNumber="1282" MinorBuildNumber="22" Version="V2017_04_14"
xmlns="http://schemas.microsoft.com/exchange/services/2006/types" />
</soap11:Header>
<soap11:Body
xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/">
<m:GetStreamingEventsResponse
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"
xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
<m:ResponseMessages>
<m:GetStreamingEventsResponseMessage ResponseClass="Success">
<m:ResponseCode>NoError</m:ResponseCode>
<m:ConnectionStatus>Closed</m:ConnectionStatus>
</m:GetStreamingEventsResponseMessage>
</m:ResponseMessages>
</m:GetStreamingEventsResponse>
</soap11:Body>
</Envelope>
这个问题我也运行遇到过一次,不知道你是不是也一样。我在使用分块 t运行sfer 编码的 HTTP 上使用 EWS,并且也仅在超时时收到响应。事实证明,终止 0 块仅在超时时发送,而不是在每次响应后发送,因此我一直在等待更多数据直到超时。
请注意,超时时间短并不是太糟糕,因为您可能希望在单个 GetEvents 请求中使用多个订阅,并且您无法在 运行 GetEvents 请求中添加或删除订阅。
"GetStreamingEvents" 回复确实 流式传输。
这意味着 http 连接保持打开状态,并且通过它发送通知比标准 request/response 机制更连续。这类似于流式传输视频的工作方式。您不会对整个视频执行单个请求。相反,您会在发送视频时从视频中读取流数据,并进行相应处理。
您需要以类似的方式处理对 "GetStreamingEvents" 的回复。
问题中提供的详细信息并未显示您如何处理响应,但我猜您使用的是 API,它只是获取 URL 和 return 是一个回应。这对于像 "StreamingSubscriptionRequest" 这样的标准请求非常有用,但它不适用于流式响应。
仅获取 url 的API 不会 return 直到收到完整响应 and/or 连接关闭。这就是为什么在超时到期之前您似乎没有收到流媒体事件的原因。
事实上,您正在 接收这些事件,只是没有在它们传入时读取和处理它们。
为此,您需要使用 API 允许您连接到 HTTP 服务器并在数据到达时从该连接读取。对于 iOS,这就像在 NSURLConnection 上实现 [connection didReceiveData:] 委托方法一样简单。据推测,有一些类似的更高级别的机制可以在您的环境中使用。