I think I've exhausted my options on this one. I have searched over the internet for days and couldn't find anyone with a similar problem.
I'm using the EWS Java API 1.2.1 to connect to an Exchange server and open my inbox folder to look for emails. Here is my code:
import java.net.URI;
import microsoft.exchange.webservices.data.*;
public class Connection {
/**
* @param args
*/
public static void main(String[] args) throws Exception {
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
ExchangeCredentials credentials = new WebCredentials("myUser", "myPass");
service.setCredentials(credentials);
service.setUrl(new URI("https://example.com/ews/exchange.asmx"));
service.setTraceEnabled(true);
Folder inbox = Folder.bind(service, WellKnownFolderName.Inbox);
System.out.println("messages: " + inbox.getTotalCount());
}
}
When I run it, I get the following error:
Exception in thread "main" microsoft.exchange.webservices.data.ServiceLocalException: https://example.com/ews/exchange.asmx : Connection error
at microsoft.exchange.webservices.data.ExchangeServiceBase.prepareHttpWebRequestForUrl(Unknown Source)
at microsoft.exchange.webservices.data.ExchangeService.prepareHttpWebRequest(Unknown Source)
at microsoft.exchange.webservices.data.ServiceRequestBase.buildEwsHttpWebRequest(Unknown Source)
at microsoft.exchange.webservices.data.ServiceRequestBase.validateAndEmitRequest(Unknown Source)
at microsoft.exchange.webservices.data.SimpleServiceRequestBase.internalExecute(Unknown Source)
at microsoft.exchange.webservices.data.MultiResponseServiceRequest.execute(Unknown Source)
at microsoft.exchange.webservices.data.ExchangeService.bindToFolder(Unknown Source)
at microsoft.exchange.webservices.data.ExchangeService.bindToFolder(Unknown Source)
at microsoft.exchange.webservices.data.Folder.bind(Unknown Source)
at microsoft.exchange.webservices.data.Folder.bind(Unknown Source)
at Connection.main(Connection.java:22)
I thought it could be something blocking my connection attempt but it does work with the above URL and User credentials when I use the JWebServices API.
BTW, I can also access the WSDL from my browser.
Any clues?
Thanks in advance!