我正在尝试与 postman 一起测试 EWS。我尝试从 https://outlook.office365.com/EWS/Exchange.asmx 获取 WSDL ,但从链接返回的 WSDL 会抛出未找到错误。
我能够从 https://outlook.office365.com/ews/services.wsdl 获取 WDSL经过基本身份验证后。
用于执行 SOAP 调用
- 我尝试向 https://outlook.office365.com/ews/services.wsdl 发送 POST 请求,这导致了 HTTP 405 方法不允许。
- 我尝试向 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/