2016-04-29 89 views
0

我在查詢Microsoft Exchange Server Web服務以獲取某些文件夾中的項目時遇到問題。按照此順序,我可以向方法expandDL和方法findFolders發出請求。這些工作正常。但是,當我用findItems向所有找到的文件夾發出請求時,我會收到400個錯誤消息,並且沒有錯誤消息。查詢Exchange Web服務使用WildFly和Apache CXF提供錯誤請求(400)

我認爲這個問題是有關Querying Exchange Web Services fails with 400 Bad Request

我使用的是WildFly 10和Java 1.8。 Apache CXF被用作web服務調用的框架。 Exchange服務器的版本,2013年

有兩種意見,使這個問題一種神祕的,至少對我來說:

  1. 當我做一個findItem要求,它有大約十一FolderIdType秒。結果總是400錯誤請求。我可以從請求中刪除一些文件夾,並最終在findItem請求中只有四個文件夾時,一切正常。只要只有四個或更少,我刪除哪個文件夾也無關緊要!看我的肥皂請求:

    <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>[email protected]</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> 
    

    當然,我也有一些限制,如日期內。

    我從Exchange服務器的入站消息看起來像這樣:

    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] 
    } 
    
  2. 我可以使用微軟的EWSEditor並張貼完全相同的SOAP請求到同一個Exchange服務器。令人驚訝的是,我以我想要的方式獲得了成功的迴應。

如果任何人可以請指點我的方向如何解決這個問題,這將不勝感激。

回答

0

好吧,我終於找到了我的問題。在Apache CXF中,我必須禁用塊組合:

import org.apache.cxf.endpoint.Client; 
import org.apache.cxf.frontend.ClientProxy; 
... 
Client client = ClientProxy.getClient(port); 
HTTPConduit conduit = (HTTPConduit) client.getConduit(); 
HTTPClientPolicy policy = conduit.getClient(); 
if(policy == null) { 
    policy = new HTTPClientPolicy(); 
} 
policy.setAllowChunking(false); 
相關問題