EWS GetStreamingEvents。仅通过超时

时间:2017-07-28 09:51:57

标签: ios xml office365 exchangewebservices rapidxml

在我的iOS应用中,我试图在this manual之后从EWS获取流媒体事件。首先,我订阅通知,接收订阅ID,然后执行GetStreamingEvents请求。订阅过程是成功的,但是获取流媒体事件不是。我只是通过超时收到回复。是的,它确实包含所有通知,所以没有问题,但我希望一旦发生事件而不是在请求时间结束时收到响应。

所以我启动了Charles并检查了Mac Mail应用的流量。我可以看到它在发出GetStreamingEvents请求后立即收到一个响应,然后每次事件发生时都会按预期成功接收响应。所以我让我的XML看起来完全像Mac Mail应用程序,但仍然没有运气。

这是我的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 Mail应用程序的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>

2 个答案:

答案 0 :(得分:1)

我也遇到过这个问题,但我不知道你是否也这样。我使用带有分块传输编码的HTTP上的EWS,并且仅在超时时收到响应。事实证明,终止0块只是在超时发送,而不是在每次响应之后发送,因此我总是等待更多数据,直到超时。

请注意,由于您可能希望在单个GetEvents请求中使用多个订阅,并且无法从正在运行的GetEvents请求中添加或删除订阅,因此具有较低的超时并不是太糟糕。

答案 1 :(得分:1)

&#34; GetStreamingEvents&#34;回复真的 流式传输。

这意味着http连接保持打开状态,并且通过比标准请求/响应机制更多的连续流来发送通知。这与流视频的工作方式类似。您不会对整个视频执行任何请求。相反,您将在视频发送时从视频中读取流数据,并相应地处理它。

您需要处理对&#34; GetStreamingEvents&#34;的响应。以类似的方式。

问题中提供的详细信息并未显示您如何处理回复,但我猜测您正在使用的API只是提取URL并返回响应。这对于#34; StreamingSubscriptionRequest&#34;等标准请求非常有用,但它不适用于流式响应。

只需获取网址的API就不会返回,直到收到完整的响应和/或连接关闭为止。这就是为什么在超时到期之前您似乎没有收到流式事件的原因。

事实上,你 接收这些事件,你只是没有阅读它们并在它们进来时对它们进行处理。

要做到这一点,您需要使用一个API,允许您连接到http服务器并在数据到达时从该连接读取。对于iOS,这就像在NSURLConnection上实现[connection didReceiveData:]委托方法一样简单。据推测,有一些类似的高级机制可以在您的环境中使用。