soap - 使用 postman 测试 Microsoft EWS(Exchange Web 服务)

标签 soap outlook exchange-server exchangewebservices

我正在尝试与 postman 一起测试 EWS。我尝试从 https://outlook.office365.com/EWS/Exchange.asmx 获取 WSDL ,但从链接返回的 WSDL 会抛出未找到错误。

然后在关注此处的对话后,https://social.msdn.microsoft.com/Forums/lync/en-US/07a01fbe-ef5e-4b9c-b1a2-be0945d4b621/how-to-get-serviceswsdl-for-office-365?forum=exchangesvrdevelopment .

我能够从 https://outlook.office365.com/ews/services.wsdl 获取 WDSL经过基本身份验证后。

用于执行 SOAP 调用

  1. 我尝试向 https://outlook.office365.com/ews/services.wsdl 发送 POST 请求,这导致了 HTTP 405 方法不允许。
  2. 我尝试向 https://outlook.office365.com/EWS/Exchange.asmx 发送 POST 请求,返回以下响应。
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Header>
        <Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">*</Action>
    </s:Header>
    <s:Body>
        <s:Fault>
            <faultcode xmlns:a="http://schemas.microsoft.com/exchange/services/2006/types">a:ErrorInvalidRequest</faultcode>
            <faultstring xml:lang="en-US">The request is invalid.</faultstring>
            <detail>
                <e:ResponseCode xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors">ErrorInvalidRequest</e:ResponseCode>
                <e:Message xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors">The request is invalid.</e:Message>
            </detail>
        </s:Fault>
    </s:Body>
</s:Envelope>

我的 XML POST 内容例如是这样的

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
               xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types"
               xmlns:m="https://schemas.microsoft.com/exchange/services/2006/messages">
   <soap:Header>
      <t:RequestServerVersion Version="Exchange2006" />
   </soap:Header>
   <soap:Body >
      <m:FindPeople>
         <m:IndexedPageItemView BasePoint="Beginning" MaxEntriesReturned="100" Offset="0"/>
         <m:ParentFolderId>
            <t:DistinguishedFolderId Id="contacts"/>
         </m:ParentFolderId>
      </m:FindPeople>
   </soap:Body>
</soap:Envelope>

我正在尝试遵循 SOAP 请求 ( https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/findpeople-operation )。我错过了什么吗?

最佳答案

您的帖子有多个错误

 <t:RequestServerVersion Version="Exchange2006" />

这是不正确的,也许你的意思是没有 Exchange2006

 <t:RequestServerVersion Version="Exchange2016" />

您还已经将命名空间从 http 修改为 https,您不应该触及这些命名空间(这并不意味着它将使用 http(或 https),这些只是命名空间声明,您的更改只会使您的请求无效)

例如工作请求看起来像

<?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" 
xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
  <soap:Header>
    <t:RequestServerVersion Version="Exchange2016" />
  </soap:Header>
   <soap:Body >
      <m:FindPeople>
         <m:IndexedPageItemView BasePoint="Beginning" MaxEntriesReturned="100" Offset="0"/>
         <m:ParentFolderId>
            <t:DistinguishedFolderId Id="contacts"/>
         </m:ParentFolderId>
      </m:FindPeople>
   </soap:Body>
</soap:Envelope>

关于soap - 使用 postman 测试 Microsoft EWS(Exchange Web 服务),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60420785/

相关文章:

php - 无法使用 SSL 连接到 test.salesforce.com

regex - 使用 powershell 捕获数组中的正则表达式匹配

outlook - 如何更新现有的office插件?

c# - 如何在 C# 中检测目标服务器中安装了哪个版本的 exchange?

java - 无法在短时间内发送太多电子邮件

c# - 按类别搜索 Exchange Server EWS

java - 比较 WSDL 中 xsd 中的属性值

php - 使用 PHP 解析来自 WSDL 的响应

java - 如何在 Spring 中开发可以作为 REST 和 SOAP 公开的 Web 服务?

excel - 导出到 Excel 的电子邮件数据 - 按接收日期排序