对 Exchange 服务器的流通知订阅不起作用
Stream notifications subscription to Exchange server not working
我试图将通知从交换服务器流式传输到我的 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"
}
我收到带有订阅 ID 的以下响应:
{
"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="
}
根据文档,下一步是使用订阅 ID 发送获取 strsaming 事件请求:
{
"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>
我认为在线文档不正确,工作请求应该看起来像
<?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 元素。 (不知道为什么doco错了)
干杯
格伦
我试图将通知从交换服务器流式传输到我的 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"
}
我收到带有订阅 ID 的以下响应:
{
"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="
}
根据文档,下一步是使用订阅 ID 发送获取 strsaming 事件请求:
{
"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>
我认为在线文档不正确,工作请求应该看起来像
<?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 元素。 (不知道为什么doco错了)
干杯 格伦