Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The Autodiscover service couldn't be located

I am using EWS Java API 1.1 to access an Exchange 2010 account as follows:

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());

I am getting the following exception:

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)
like image 954
Mahmoud Saleh Avatar asked Oct 08 '12 15:10

Mahmoud Saleh


People also ask

How do I fix Autodiscover problems?

Go to the Outlook application in the application menu, right-click it, and select the option 'Test Email AutoConfiguration. ' Input the user credentials, check the option of 'User Autodiscover,' and click the Test button. The system will check the connection and provide a 'succeeded' message on a clean connection.

What is the Autodiscover service?

The Autodiscover service minimizes user configuration and deployment steps by providing clients access to Exchange features. For Exchange Web Services (EWS) clients, Autodiscover is typically used to find the EWS endpoint URL.


1 Answers

It works fine after removing the autodiscover:

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

and setting it manually as follows:

service.setUrl(new java.net.URI(
                    "https://myhostname/EWS/Exchange.asmx"));
like image 91
Mahmoud Saleh Avatar answered Sep 23 '22 23:09

Mahmoud Saleh