2016-03-07 79 views
0

我試圖將交換服務器的通知流式傳輸到我的meterojs應用程序。對Exchange服務器不起作用的流通知訂閱

我發送以下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=" 
} 

每文檔下一步是對發獲得strsaming事件與訂閱請求ID:

{ 
    "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" 
} 

在此我得到回覆wi th狀態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>[email protected]</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是錯誤的)

乾杯 格倫

+0

可否請你看看我的編輯。謝謝。 – eomeroff

+1

它是一個數據類型問題我想你需要把連接時間放在引號中,例如「ConnectionTimeout」:'30'給出了其他使用整數的例子。 –

+0

你可以請看看我的這個問題http://stackoverflow.com/questions/35863589/meteor-js-push-notifications-to-exchange-server它是繼續從這一個故事。謝謝。 – eomeroff