From b0ea531d3a82129d9ec89058fb1aec79755eed22 Mon Sep 17 00:00:00 2001 From: mguessan Date: Thu, 12 Feb 2015 15:31:43 +0000 Subject: [PATCH] EWS: update checkEndPointUrl, send get root folder request instead of static wsdl request no longer available on Office365 git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@2333 3d1905a2-6b24-0410-a738-b14d5a86fcbd --- src/java/davmail/exchange/ews/EwsExchangeSession.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/java/davmail/exchange/ews/EwsExchangeSession.java b/src/java/davmail/exchange/ews/EwsExchangeSession.java index 064a3dc7..4ba1485a 100644 --- a/src/java/davmail/exchange/ews/EwsExchangeSession.java +++ b/src/java/davmail/exchange/ews/EwsExchangeSession.java @@ -172,16 +172,13 @@ public class EwsExchangeSession extends ExchangeSession { * @throws IOException on error */ protected void checkEndPointUrl(String endPointUrl) throws IOException { - HttpMethod checkMethod = new GetMethod(endPointUrl); - checkMethod.setPath("/ews/services.wsdl"); - checkMethod.setFollowRedirects(false); + GetFolderMethod checkMethod = new GetFolderMethod(BaseShape.ID_ONLY, DistinguishedFolderId.getInstance(null, DistinguishedFolderId.Name.root), null); try { int status = DavGatewayHttpClientFacade.executeNoRedirect(httpClient, checkMethod); if (status == HttpStatus.SC_UNAUTHORIZED) { // retry with /ews/exchange.asmx checkMethod.releaseConnection(); - checkMethod = new GetMethod(endPointUrl); - checkMethod.setFollowRedirects(true); + checkMethod = new GetFolderMethod(BaseShape.ID_ONLY, DistinguishedFolderId.getInstance(null, DistinguishedFolderId.Name.root), null); status = DavGatewayHttpClientFacade.executeNoRedirect(httpClient, checkMethod); if (status == HttpStatus.SC_UNAUTHORIZED) { throw new DavMailAuthenticationException("EXCEPTION_AUTHENTICATION_FAILED"); @@ -203,7 +200,9 @@ public class EwsExchangeSession extends ExchangeSession { if (method != null) { method.releaseConnection(); } - directEws = method == null || "/ews/services.wsdl".equalsIgnoreCase(method.getPath()); + directEws = method == null + || "/ews/services.wsdl".equalsIgnoreCase(method.getPath()) + || "/ews/exchange.asmx".equalsIgnoreCase(method.getPath()); // options page is not available in direct EWS mode if (!directEws) {