Подписка на потоковые уведомления на сервере Exchange не работает

Я пытался передавать уведомления с сервера Exchange на мое приложение Meterojs.

Я отправляю следующее SOAP-сообщение как запрос на потоковую подписку:

{
   "body":{
      "m:Subscribe":{
         "m:StreamingSubscriptionRequest":{
            "t:FolderIds":{
               "t:DistinguishedFolderId":{
                  "attributes":[
                     {
                        "Id":"calendar"
                     }
                  ]
               }
            },
            "t:EventTypes":{
               "t:EventType":"CreatedEvent"
            }
         }
      }
   },
   "headers":{
      "Authorization":"Basic YW5kZXJzLmthcmxzc29uQGNlcnR1c2ludGVybmF0aW9uYWwub25taWNyb3NvZnQuY29tOmxpaXNzc29vb280MzIh"
   },
   "additionalNamespaces":[
      "xmlns:m=\"http://schemas.microsoft.com/exchange/services/2006/messages\"",
      "xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\""
   ],
   "soapHeader":"",
   "method":"POST",
   "url":"https://outlook.office365.com/EWS/Exchange.asmx"
}

Я получаю следующий ответ с идентификатором подписки:

{
   "xmlns:s":"http://schemas.xmlsoap.org/soap/envelope/",
   "MajorVersion":"15",
   "MinorVersion":"1",
   "MajorBuildNumber":"434",
   "MinorBuildNumber":"14",
   "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",
   "xmlns:m":"http://schemas.microsoft.com/exchange/services/2006/messages",
   "xmlns:t":"http://schemas.microsoft.com/exchange/services/2006/types",
   "ResponseClass":"Success",
   "m:ResponseCode":"NoError",
   "m:SubscriptionId":"JwBkYjVwcjA3bWIxMzk3LmV1cnByZDA3LnByb2Qub3V0bG9vay5jb20QAAAA/wYNryw5gEeJFs3T7NXJvglEUWvERtMIEAAAAPP2lIvBykJBqcK1FSVk+mk="
}

Следующим шагом в документации является отправка запроса на получение событий озвучивания с идентификатором подписки:

{
   "body":{
      "GetStreamingEvents":{
         "attributes":[
            {
               "xmlns":"http://schemas.microsoft.com/exchange/services/2006/messages"
            }
         ],
         "SubscriptionId":"JwBkYjVwcjA3bWIxMzk3LmV1cnByZDA3LnByb2Qub3V0bG9vay5jb20QAAAA/wYNryw5gEeJFs3T7NXJvglEUWvERtMIEAAAAPP2lIvBykJBqcK1FSVk+mk=",
         "ConnectionTimeout":30
      }
   },
   "headers":{
      "Authorization":"Basic YW5kZXJzLmthcmxzc29uQGNlcnR1c2ludGVybmF0aW9uYWwub25taWNyb3NvZnQuY29tOmxpaXNzc29vb280MzIh"
   },
   "additionalNamespaces":[
      "xmlns:m=\"http://schemas.microsoft.com/exchange/services/2006/messages\"",
      "xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\""
   ],
   "soapHeader":{
      "t:RequestServerVersion":{
         "attributes":[
            {
               "Version":"Exchange2013"
            }
         ]
      }
   },
   "method":"POST",
   "url":"https://outlook.office365.com/EWS/Exchange.asmx"
}

На это я получаю ответ со статусом 500 и телом ответа:

<?xml version=\"1.0\" encoding=\"utf-8\"?>
<s:Envelope
    xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">
    <s:Body>
        <s:Fault>
            <faultcode
                xmlns:a=\"http://schemas.microsoft.com/exchange/services/2006/types\">a:ErrorSchemaValidation
            </faultcode>
            <faultstring xml:lang=\"en-US\">The request failed schema validation: The element 'GetStreamingEvents' in namespace 'http://schemas.microsoft.com/exchange/services/2006/messages' has invalid child element 'SubscriptionId' in namespace 'http://schemas.microsoft.com/exchange/services/2006/messages'. List of possible elements expected: 'SubscriptionIds' in namespace 'http://schemas.microsoft.com/exchange/services/2006/messages'.</faultstring>
            <detail>
                <e:ResponseCode
                    xmlns:e=\"http://schemas.microsoft.com/exchange/services/2006/errors\">ErrorSchemaValidation
                </e:ResponseCode>
                <e:Message
                    xmlns:e=\"http://schemas.microsoft.com/exchange/services/2006/errors\">The request failed schema validation.
                </e:Message>
                <t:MessageXml
                    xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\">
                    <t:LineNumber>3</t:LineNumber>
                    <t:LinePosition>201</t:LinePosition>
                    <t:Violation>The element 'GetStreamingEvents' in namespace 'http://schemas.microsoft.com/exchange/services/2006/messages' has invalid child element 'SubscriptionId' in namespace 'http://schemas.microsoft.com/exchange/services/2006/messages'. List of possible elements expected: 'SubscriptionIds' in namespace 'http://schemas.microsoft.com/exchange/services/2006/messages'.</t:Violation>
                </t:MessageXml>
            </detail>
        </s:Fault>
    </s:Body>
</s:Envelope>

Можете ли вы дать совет по этому вопросу.

Обновить:

Новый запрос с исправлениями:

{
   "body":{
      "m:GetStreamingEvents":{
         "m:SubscriptionIds":{
            "t:SubscriptionId":"JwBhbTRwcjA3bWIxMzk1LmV1cnByZDA3LnByb2Qub3V0bG9vay5jb20QAAAAnjsBVFou+0u0dglnKKEJ0CDsxAkYR9MIEAAAAPP2lIvBykJBqcK1FSVk+mk="
         },
         "m:ConnectionTimeout":30
      }
   },
   "headers":{
      "Authorization":"Basic YW5kZXJzLmthcmxzc29uQGNlcnR1c2ludGVybmF0aW9uYWwub25taWNyb3NvZnQuY29tOmxpaXNzc29vb280MzIh"
   },
   "additionalNamespaces":[
      "xmlns:m=\"http://schemas.microsoft.com/exchange/services/2006/messages\"",
      "xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\""
   ],
   "soapHeader":{
      "t:RequestServerVersion":{
         "attributes":[
            {
               "Version":"Exchange2013"
            }
         ]
      }
   },
   "method":"POST",
   "url":"https://outlook.office365.com/EWS/Exchange.asmx"
}

Новый ответ с другой ошибкой:

<?xml version=\"1.0\" encoding=\"utf-8\"?>
<s:Envelope
    xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">
    <s:Body>
        <s:Fault>
            <faultcode
                xmlns:a=\"http://schemas.microsoft.com/exchange/services/2006/types\">a:ErrorSchemaValidation
            </faultcode>
            <faultstring xml:lang=\"en-US\">The request failed schema validation: The 'http://schemas.microsoft.com/exchange/services/2006/messages:ConnectionTimeout' element is invalid - The value 'undefined' is invalid according to its datatype 'http://schemas.microsoft.com/exchange/services/2006/types:StreamingSubscriptionConnectionTimeoutType' - The string 'undefined' is not a valid Int32 value.</faultstring>
            <detail>
                <e:ResponseCode
                    xmlns:e=\"http://schemas.microsoft.com/exchange/services/2006/errors\">ErrorSchemaValidation
                </e:ResponseCode>
                <e:Message
                    xmlns:e=\"http://schemas.microsoft.com/exchange/services/2006/errors\">The request failed schema validation.
                </e:Message>
                <t:MessageXml
                    xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\">
                    <t:LineNumber>3</t:LineNumber>
                    <t:LinePosition>361</t:LinePosition>
                    <t:Violation>The 'http://schemas.microsoft.com/exchange/services/2006/messages:ConnectionTimeout' element is invalid - The value 'undefined' is invalid according to its datatype 'http://schemas.microsoft.com/exchange/services/2006/types:StreamingSubscriptionConnectionTimeoutType' - The string 'undefined' is not a valid Int32 value.</t:Violation>
                </t:MessageXml>
            </detail>
        </s:Fault>
    </s:Body>
</s:Envelope>

1 ответ

Решение

Я не думаю, что онлайн-документация верна, рабочий запрос должен выглядеть

        <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Header>
        <t:RequestServerVersion Version="Exchange2013" />
        <t:ExchangeImpersonation>
          <t:ConnectingSID>
            <t:SmtpAddress>target@Mailbox.com</t:SmtpAddress>
          </t:ConnectingSID>
        </t:ExchangeImpersonation>
      </soap:Header>
      <soap:Body>
        <m:GetStreamingEvents>
          <m:SubscriptionIds>
            <t:SubscriptionId>JwB0eTFwcjA0bWIwNzE4LmFwY3ByZDA0LnByb2Qub3V0bG9vay5jb20QAAAAhKGBpeZ5jEWJiN8rkO4xNxQ6jxrvRtMIEAAAAGhtpJbjoodMsSowkUdd9qk=</t:SubscriptionId>
          </m:SubscriptionIds>
          <m:ConnectionTimeout>15</m:ConnectionTimeout>
        </m:GetStreamingEvents>
      </soap:Body>
    </soap:Envelope>

Так что ошибка, которую вы получаете, имеет смысл, потому что вы пропустили элемент SubscriptionIds. (Не уверен, почему Доко не так)

Ура Глен

Другие вопросы по тегам