Lordrem
Lordrem

Reputation: 133

EWS XML Query No answer

I developed a Java interface that connects to a Exchange Web Services and it works until I perform request.

My problem is that the answers are always empty. For example, if I send the following query to a 2007 exchange server:

<?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>

The answer I get at the end is a simple normal HTTP packet without any error. Here is its contents (I did some System.out to output this):

################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 : 

As you can see, the length of the content is empty. It seems that the server accepts the request, do something with it, and replies an empty result.

Do you have an idea why?

Thx!

Upvotes: 1

Views: 394

Answers (2)

Lordrem
Lordrem

Reputation: 133

I found the mighty trick that solves everything. The most important and ONLY REQUIRED header of the HTTP post message that you send to the server is the Content-Type value. Every other header is optional and i'm not even sure they are used for anything. The Content-Type is the key that unlocks everything.

Upvotes: 1

Sirius
Sirius

Reputation: 1

Valid FindItem request/response with EWS to search for messages in the Inbox folder:

Request:

<FindItem Traversal="Shallow" xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<ItemShape><t:BaseShape>IdOnly</t:BaseShape></ItemShape>
<ParentFolderIds><t:DistinguishedFolderId Id="inbox"></t:DistinguishedFolderId></ParentFolderIds></FindItem>

JWebServices for Exchange 1.1 evaluation version, www.independentsoft.com.

Response:

<?xml version="1.0" encoding="utf-8"?><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header><h:ServerVersionInfo MajorVersion="14" MinorVersion="16" MajorBuildNumber="175" MinorBuildNumber="8" Version="Exchange2010_SP2" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"/></s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><m:FindItemResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<m:ResponseMessages><m:FindItemResponseMessage ResponseClass="Success"><m:ResponseCode>NoError</m:ResponseCode><m:RootFolder TotalItemsInView="1" IncludesLastItemInRange="true">
<t:Items><t:Message><t:ItemId Id="AAMkAGM2NmE0NDQ4LTk0ZDAtNDRmZi1iYzJiLTI3ZGFiZTIwNTE4NQBGAAAAAADMQnRUWVgLTKClbuKuQmcEBwA5UIf+H7cbQZVv4gNmZSgmAAAA2iK7AAA5UIf+H7cbQZVv4gNmZSgmAAAD76voAAA=" ChangeKey="CQAAABYAAAA5UIf+H7cbQZVv4gNmZSgmAAAD77IT"/></t:Message></t:Items>
</m:RootFolder></m:FindItemResponseMessage></m:ResponseMessages></m:FindItemResponse></s:Body></s:Envelope>

Upvotes: 0

Related Questions