我正在使用EWS Java API 1.1来访问Exchange 2010帐户,如下所示:

ExchangeService service = new ExchangeService();
ExchangeCredentials credentials = new WebCredentials(email,
    password);
service.setCredentials(credentials);
service.autodiscoverUrl("[email protected]");
Folder inbox = Folder.bind(service, WellKnownFolderName.Inbox);
System.out.println("messages: " + inbox.getTotalCount());

我收到以下异常:
08/10/2012 05:11:35 م org.apache.commons.httpclient.HttpMethodDirector executeWithRetry
INFO: I/O exception (java.net.ConnectException) caught when processing request: Connection timed out: connect
08/10/2012 05:11:35 م org.apache.commons.httpclient.HttpMethodDirector executeWithRetry
INFO: Retrying request
08/10/2012 05:11:56 م org.apache.commons.httpclient.HttpMethodDirector executeWithRetry
INFO: I/O exception (java.net.ConnectException) caught when processing request: Connection timed out: connect
08/10/2012 05:11:56 م org.apache.commons.httpclient.HttpMethodDirector executeWithRetry
INFO: Retrying request
08/10/2012 05:12:17 م org.apache.commons.httpclient.HttpMethodDirector executeWithRetry
INFO: I/O exception (java.net.ConnectException) caught when processing request: Connection timed out: connect
08/10/2012 05:12:17 م org.apache.commons.httpclient.HttpMethodDirector executeWithRetry
INFO: Retrying request
microsoft.exchange.webservices.data.AutodiscoverLocalException: The Autodiscover service couldn't be located.
    at microsoft.exchange.webservices.data.AutodiscoverService.internalGetLegacyUserSettings(Unknown Source)
    at microsoft.exchange.webservices.data.AutodiscoverService.getLegacyUserSettings(Unknown Source)
    at microsoft.exchange.webservices.data.AutodiscoverService.internalGetLegacyUserSettings(Unknown Source)
    at microsoft.exchange.webservices.data.AutodiscoverService.getUserSettings(Unknown Source)
    at microsoft.exchange.webservices.data.ExchangeService.getAutodiscoverUrl(Unknown Source)
    at microsoft.exchange.webservices.data.ExchangeService.autodiscoverUrl(Unknown Source)
    at microsoft.exchange.webservices.data.ExchangeService.autodiscoverUrl(Unknown Source)
    at main.java.TestMail.main(TestMail.java:22)

最佳答案

删除自动发现后,它可以正常工作:

service.autodiscoverUrl("[email protected]");

并手动进行如下设置:
service.setUrl(new java.net.URI(
                    "https://myhostname/EWS/Exchange.asmx"));

关于java - 找不到自动发现服务,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/12785050/

10-09 19:16