EWS Java API - 连接错误
EWS Java API - Connection error
我想我已经用尽了这个选项。我在互联网上搜索了几天,但没有找到有类似问题的人。
我正在使用 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。
有什么线索吗?
提前致谢!
这可能是因为引用了错误的 JAR Class。
您使用的是什么 JAR。以及这里使用的是哪个版本的 EWS API??
我在使用 EWS API 1.2 时遇到了同样的问题,在参考了以下 JAR 后,它得到了解决。
EWSJavaAPI_1.2original.jar,
EWSJavaAPIWithJars_1.2.1.jar,
httpclient-4.2.5.jar,
httpcore-4.2.4.jar,
jcifs-1.3.17.jar,
commons-codec-1.7.jar,
commons-logging-1.1.1.jar
EWSJavaAPI_1.2original.jar - 这是微软相关的 Classes
EWSJavaAPIWithJars_1.2.1.jar - 这个有它的连接相关 Classes.
尝试添加这些 JAR。
此致,
拉梅什·G.
我想我已经用尽了这个选项。我在互联网上搜索了几天,但没有找到有类似问题的人。
我正在使用 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。
有什么线索吗?
提前致谢!
这可能是因为引用了错误的 JAR Class。
您使用的是什么 JAR。以及这里使用的是哪个版本的 EWS API??
我在使用 EWS API 1.2 时遇到了同样的问题,在参考了以下 JAR 后,它得到了解决。
EWSJavaAPI_1.2original.jar, EWSJavaAPIWithJars_1.2.1.jar, httpclient-4.2.5.jar, httpcore-4.2.4.jar, jcifs-1.3.17.jar, commons-codec-1.7.jar, commons-logging-1.1.1.jar
EWSJavaAPI_1.2original.jar - 这是微软相关的 Classes EWSJavaAPIWithJars_1.2.1.jar - 这个有它的连接相关 Classes.
尝试添加这些 JAR。
此致,
拉梅什·G.