我开发了一个连接到 Exchange Web 服务的 Java 接口(interface),它在我执行请求之前一直有效。
我的问题是答案总是空的。例如,如果我将以下查询发送到 2007 Exchange 服务器:
<?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\">"
<soap:Header>
<t:RequestServerVersion Version=\"Exchange2007\"/>"
</soap:Header>"
<soap:Body>"
<FindItem xmlns=\"http://schemas.microsoft.com/exchange/services/2006/messages\" xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\" Traversal=\"Shallow\">"
<ItemShape>"
<t:BaseShape>IdOnly</t:BaseShape>"
</ItemShape>
<ParentFolderIds>
<t:FolderId Id="inbox" />
</ParentFolderIds>"
</FindItem>
</soap:Body>
</soap:Envelope>
我最后得到的答案是一个简单的普通 HTTP 数据包,没有任何错误。这是它的内容(我做了一些 System.out
来输出它):
################ANSWER################
#Header : Date: Thu, 09 Aug 2012 09:36:53 GMT#
#Header : Server: Microsoft-IIS/6.0#
#Header : X-Powered-By: ASP.NET#
#Header : X-AspNet-Version: 2.0.50727#
#Header : Cache-Control: private#
#Header : Content-Length: 0#
################DATA################
Data :
可以看到,内容长度为空。看来服务器接受了请求,对其进行了一些处理,然后回复了一个空结果。
你知道为什么吗?
谢谢!
最佳答案
我找到了解决一切问题的强大技巧。您发送到服务器的 HTTP post 消息中最重要且唯一必需的 header 是 Content-Type
值。其他所有 header 都是可选的,我什至不确定它们是否用于任何用途。 Content-Type
是解锁一切的 key 。
关于java - EWS XML 查询无答案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11880633/