I have a problem while querying the Microsoft Exchange Server WebServices to get Items in certain folders. In this order, I can make a request to the method expandDL
and to the method findFolders
. These work fine. But when I then make a request to findItems
with all the found folders, I get 400 Bad Request with no error message.
I think this question is related to Querying Exchange Web Services fails with 400 Bad Request
I am using a WildFly 10 and Java 1.8. Apache CXF is used as framework for the webservice calls. The Exchange Server is of version 2013.
There are two observations that make this issue kind of mysterious, at least for me:
When I make a
findItem
request, it has about elevenFolderIdType
s. The result is always a 400 Bad Request. I can remove some folders from the request and eventually when there are only four folders in thefindItem
request, everything works fine. It also doesn't matter which folder I remove as long as there are only four or less! See my soap request:<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Header> <ns2:ExchangeImpersonation xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:ns2="http://schemas.microsoft.com/exchange/services/2006/types"> <ns2:ConnectingSID> <ns2:PrimarySmtpAddress>tobeimpersonated@example.com</ns2:PrimarySmtpAddress> </ns2:ConnectingSID> </ns2:ExchangeImpersonation> <ns2:RequestServerVersion xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:ns2="http://schemas.microsoft.com/exchange/services/2006/types" Version="Exchange2007_SP1"/> </soap:Header> <soap:Body> <FindItem xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:ns2="http://schemas.microsoft.com/exchange/services/2006/types" Traversal="Shallow"> <ItemShape> <ns2:BaseShape>IdOnly</ns2:BaseShape> <ns2:IncludeMimeContent>false</ns2:IncludeMimeContent> <ns2:BodyType>Best</ns2:BodyType> <ns2:AdditionalProperties> <ns2:FieldURI FieldURI="message:InternetMessageId"/> <ns2:FieldURI FieldURI="item:Subject"/> <ns2:ExtendedFieldURI PropertyTag="0x300B" PropertyType="Binary"/> <ns2:ExtendedFieldURI PropertyTag="0x3704" PropertyType="String"/> </ns2:AdditionalProperties> </ItemShape> <IndexedPageItemView BasePoint="Beginning" MaxEntriesReturned="20" Offset="0"/> <Restriction> <ns2:And> <ns2:Or> <ns2:IsEqualTo> <ns2:FieldURI FieldURI="item:ItemClass"/> <ns2:FieldURIOrConstant> <ns2:Constant Value="IPM.Note"/> </ns2:FieldURIOrConstant> </ns2:IsEqualTo> <ns2:IsEqualTo> <ns2:FieldURI FieldURI="item:ItemClass"/> <ns2:FieldURIOrConstant> <ns2:Constant Value="IPM.Note.SMIME.MultipartSigned"/> </ns2:FieldURIOrConstant> </ns2:IsEqualTo> <ns2:IsEqualTo> <ns2:FieldURI FieldURI="item:ItemClass"/> <ns2:FieldURIOrConstant> <ns2:Constant Value="IPM.Note.SMIME"/> </ns2:FieldURIOrConstant> </ns2:IsEqualTo> </ns2:Or> <ns2:IsEqualTo> <ns2:FieldURI FieldURI="item:IsDraft"/> <ns2:FieldURIOrConstant> <ns2:Constant Value="false"/> </ns2:FieldURIOrConstant> </ns2:IsEqualTo> <ns2:Not> <ns2:Exists> <ns2:ExtendedFieldURI PropertyName="propertyName" PropertySetId="24040483-cda4-4521-bb4e-a83fac4d19a4" PropertyType="Integer"/> </ns2:Exists> </ns2:Not> <ns2:Or> <ns2:And> <ns2:IsGreaterThan> <ns2:FieldURI FieldURI="item:DateTimeReceived"/> <ns2:FieldURIOrConstant> <ns2:Constant Value="2014-02-06T12:40:53Z"/> </ns2:FieldURIOrConstant> </ns2:IsGreaterThan> <ns2:IsLessThanOrEqualTo> <ns2:FieldURI FieldURI="item:DateTimeReceived"/> <ns2:FieldURIOrConstant> <ns2:Constant Value="2016-04-29T08:32:42Z"/> </ns2:FieldURIOrConstant> </ns2:IsLessThanOrEqualTo> </ns2:And> <ns2:And> <ns2:IsGreaterThan> <ns2:FieldURI FieldURI="item:DateTimeSent"/> <ns2:FieldURIOrConstant> <ns2:Constant Value="2014-02-06T12:40:53Z"/> </ns2:FieldURIOrConstant> </ns2:IsGreaterThan> <ns2:IsLessThanOrEqualTo> <ns2:FieldURI FieldURI="item:DateTimeSent"/> <ns2:FieldURIOrConstant> <ns2:Constant Value="2016-04-29T08:32:42Z"/> </ns2:FieldURIOrConstant> </ns2:IsLessThanOrEqualTo> </ns2:And> </ns2:Or> </ns2:And> </Restriction> <SortOrder> <ns2:FieldOrder Order="Ascending"> <ns2:FieldURI FieldURI="item:DateTimeReceived"/> </ns2:FieldOrder> </SortOrder> <ParentFolderIds> <ns2:FolderId ChangeKey="AQAAABYAAAB8br3Xlm6jQ6ESWiFFNbMfAAEtfGtC" Id="AQMkADUwYWRiMTQzLTA2ZWMtNDEyZi05ZjgyLWUyNWYwNzVjZjViNQAuAAADsJ39BzCTikK07SQtfYnJhwEA0zVBfp4xUk+7Vyc3iZW0FAA05RFXoQAAAA=="/> <ns2:FolderId ChangeKey="AQAAABYAAAB8br3Xlm6jQ6ESWiFFNbMfAAEtfH8N" Id="AQMkADUwYWRiMTQzLTA2ZWMtNDEyZi05ZjgyLWUyNWYwNzVjZjViNQAuAAADsJ39BzCTikK07SQtfYnJhwEA0zVBfp4xUk+7Vyc3iZW0FAA05RFXoAAAAA=="/> <ns2:FolderId ChangeKey="AQAAABQAAAAJFy1A7LXdQ4Jg/JYq7dhuAAFIBg==" Id="AQMkADUwYWRiMTQzLTA2ZWMtNDEyZi05ZjgyLWUyNWYwNzVjZjViNQAuAAADsJ39BzCTikK07SQtfYnJhwEA0zVBfp4xUk+7Vyc3iZW0FAA05RDn6AAAAA=="/> <ns2:FolderId ChangeKey="AgAAABYAAADTNUF+njFST7tXJzeJlbQUADTuxhMy" Id="AQMkADUwYWRiMTQzLTA2ZWMtNDEyZi05ZjgyLWUyNWYwNzVjZjViNQAuAAADsJ39BzCTikK07SQtfYnJhwEA0zVBfp4xUk+7Vyc3iZW0FAA05RDnvgAAAA=="/> <ns2:FolderId ChangeKey="AwAAABYAAAB8br3Xlm6jQ6ESWiFFNbMfAAEtfLe1" Id="AQMkADUwYWRiMTQzLTA2ZWMtNDEyZi05ZjgyLWUyNWYwNzVjZjViNQAuAAADsJ39BzCTikK07SQtfYnJhwEAfG6915Zuo0OhElohRTWzHwAAAgmBAAAA"/> <ns2:FolderId ChangeKey="AQAAABYAAAB8br3Xlm6jQ6ESWiFFNbMfAAEtfLIm" Id="AQMkADUwYWRiMTQzLTA2ZWMtNDEyZi05ZjgyLWUyNWYwNzVjZjViNQAuAAADsJ39BzCTikK07SQtfYnJhwEA0zVBfp4xUk+7Vyc3iZW0FAA05RFXngAAAA=="/> <ns2:FolderId ChangeKey="AQAAABYAAAB8br3Xlm6jQ6ESWiFFNbMfAAEtfH79" Id="AQMkADUwYWRiMTQzLTA2ZWMtNDEyZi05ZjgyLWUyNWYwNzVjZjViNQAuAAADsJ39BzCTikK07SQtfYnJhwEAfG6915Zuo0OhElohRTWzHwABJMQcGAAAAA=="/> <ns2:FolderId ChangeKey="AQAAABQAAAAJFy1A7LXdQ4Jg/JYq7dhuAAFIBA==" Id="AQMkADUwYWRiMTQzLTA2ZWMtNDEyZi05ZjgyLWUyNWYwNzVjZjViNQAuAAADsJ39BzCTikK07SQtfYnJhwEA0zVBfp4xUk+7Vyc3iZW0FAA07GTIvwAAAA=="/> <ns2:FolderId ChangeKey="AwAAABYAAAB8br3Xlm6jQ6ESWiFFNbMfAACg9DeI" Id="AQMkADUwYWRiMTQzLTA2ZWMtNDEyZi05ZjgyLWUyNWYwNzVjZjViNQAuAAADsJ39BzCTikK07SQtfYnJhwEACthrv1y0RUyxtNEACu0ptAA066kAAwAAAA=="/> <ns2:FolderId ChangeKey="AQAAABYAAAB8br3Xlm6jQ6ESWiFFNbMfAAEdND9a" Id="AQMkADUwYWRiMTQzLTA2ZWMtNDEyZi05ZjgyLWUyNWYwNzVjZjViNQAuAAADsJ39BzCTikK07SQtfYnJhwEA0zVBfp4xUk+7Vyc3iZW0FAA05RDn0wAAAA=="/> <ns2:FolderId ChangeKey="AQAAABQAAADao4wXVcs7RIo7U7kl8KntAAIkAQ==" Id="AQMkADUwYWRiMTQzLTA2ZWMtNDEyZi05ZjgyLWUyNWYwNzVjZjViNQAuAAADsJ39BzCTikK07SQtfYnJhwEACthrv1y0RUyxtNEACu0ptABAzY4ADQAAAA=="/> </ParentFolderIds> </FindItem> </soap:Body> </soap:Envelope>
Of course, I have also some restrictions like dates within it.
My Inbound message from the exchange server looks like that:
ID: 4 Response-Code: 400 Encoding: ISO-8859-1 Content-Type: Headers: { Cache-Control=[private], Content-Length=[0], Date=[Fri, 29 Apr 2016 08:32:44 GMT], request-id=[8a3d7697-3f2b-458a-904d-703d5e2f0664], Server=[Microsoft-IIS/8.5], Set-Cookie=[X-BackEndCookie=S-1-5-21-436374069-789336058-1060284298-3660=u56Lnp2ejJqBz53Nzs+ayJ3SnJ2bnNLLzMfJ0p6bzMvSx57Iyc2ensfHxsibgYHNz87J0s/K0s3Gq8/HxczNxcvK; expires=Sun, 29-May-2016 08:32:45 GMT; path=/EWS; HttpOnly, exchangecookie=5096a0de261c45019aa1523ce05cd77c; expires=Sat, 29-Apr-2017 08:32:42 GMT; path=/; HttpOnly, ClientId=MASOZZCUPEOBNCBZRFNOMQ; expires=Sat, 29-Apr-2017 08:32:42 GMT; path=/; HttpOnly], X-AspNet-Version=[4.0.30319], X-BEServer=[SABCEXH04], X-CalculatedBETarget=[sabcexh04.company.local], X-DiagInfo=[SABCEXH04], X-FEServer=[SABCEXH04], X-Powered-By=[ASP.NET] }
I can use the EWSEditor from Microsoft and post exactly the same SOAP request to the same Exchange Server. And surprisingly I get a successful response just the way I want.
If anyone can please point me in a direction how to solve this issue, that would be much appreciated.