문제

I am using EWSJavaAPI 1.1.5. I am trying to login with invalid credentials, but I don't get any exceptions.

Please advise how to detect and handle invalid login.

Here is my code:

String host = "myhost";
ExchangeService service = null;
try {
    service = new ExchangeService();
    ExchangeCredentials credentials = new WebCredentials("wrongemail",
        "wrongpass");
    service.setCredentials(credentials);
    service.setUrl(new java.net.URI("https://" + host
        + "/EWS/Exchange.asmx"));
} catch (Exception e) {
    e.printStackTrace();
}
도움이 되었습니까?

해결책

Found it, i had to bind the service to a folder:

Folder.bind(service, WellKnownFolderName.Inbox);

and if the credentials are wrong, HttpErrorException is thrown.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top