我想我已经用尽了我的选择。我已经在互联网上搜索了几天,找不到任何有类似问题的人。
我正在使用 EWS Java API 1.2.1 连接到 Exchange 服务器并打开我的收件箱文件夹以查找电子邮件。这是我的代码:
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());
}
}
当我运行它时,我收到以下错误:
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)
我认为这可能会阻止我的连接尝试,但当我使用 JWebServices API 时,它确实适用于上述 URL 和用户凭据。
顺便说一句,我也可以从我的浏览器访问 WSDL。
有什么线索吗?
提前致谢!