java - EWS Java 1.2 - 无法连接到公司 Exchange 服务器

标签 java ssl exchange-server exchangewebservices ewsjavaapi

我目前正在尝试使用 EWS Java API 连接到我们公司的 Exchange 服务器。 不幸的是,当尝试执行任何操作时(自动发现或手动使用 setUrl 后的某些其他操作)我收到以下错误:

Apr 17, 2013 7:57:10 AM org.apache.commons.httpclient.HttpMethodDirector executeWithRetry
INFO: I/O exception (java.net.ConnectException) caught when processing request: Connection refused: connect
Apr 17, 2013 7:57:10 AM org.apache.commons.httpclient.HttpMethodDirector executeWithRetry
INFO: Retrying request
Apr 17, 2013 7:57:11 AM org.apache.commons.httpclient.HttpMethodDirector executeWithRetry
INFO: I/O exception (java.net.ConnectException) caught when processing request: Connection refused: connect
Apr 17, 2013 7:57:11 AM org.apache.commons.httpclient.HttpMethodDirector executeWithRetry
INFO: Retrying request
Apr 17, 2013 7:57:12 AM org.apache.commons.httpclient.HttpMethodDirector executeWithRetry
INFO: I/O exception (java.net.ConnectException) caught when processing request: Connection refused: connect
Apr 17, 2013 7:57:12 AM org.apache.commons.httpclient.HttpMethodDirector executeWithRetry
INFO: Retrying request
Exception in thread "main" microsoft.exchange.webservices.data.ServiceRequestException: The request failed. Connection refused: connect
    at microsoft.exchange.webservices.data.ServiceRequestBase.getEwsHttpWebResponse(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.CalendarFolder.bind(Unknown Source)
    at microsoft.exchange.webservices.data.CalendarFolder.bind(Unknown Source)
    at er.dream.tgif.outlook.OutlookTest.findAppointments(OutlookTest.java:59)
    at er.dream.tgif.outlook.OutlookTest.main(OutlookTest.java:45)
Caused by: java.net.ConnectException: Connection refused: connect
    at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:75)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:157)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391)
    at java.net.Socket.connect(Socket.java:579)
    at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:618)
    at microsoft.exchange.webservices.data.EwsSSLProtocolSocketFactory.createSocket(Unknown Source)
    at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707)
    at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.open(MultiThreadedHttpConnectionManager.java:1361)
    at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387)
    at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
    at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
    at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
    at microsoft.exchange.webservices.data.HttpClientWebRequest.executeRequest(Unknown Source)
    ... 10 more

我尝试使用我的凭据登录到交换服务器 Web 界面,这工作正常。假设它可能与 SSL 问题有关,我还尝试实现一个虚拟的 TrustManager 并将其设置为 HttpsUrlConnections 的默认值。

不幸的是,这没有帮助,错误仍然存​​在。

一个值得注意的事实:在我的 Outlook 中,我可以看到 Exchange 服务器配置为使用代理服务器和特定的 SSL URL 来连接到它。 (代理身份验证设置为 NTLM) 我不太确定如何在我的编码中反射(reflect)这一点。

这可能是导致异常的原因,还是我在这里查看的是其他问题?

最佳答案

Java EWS API 的发行说明提到:

While running on Windows 7 OS, 32-bit, and if the application generates the following error : ERROR : Request failed. Unable to get response codejava.io.IOException: Authentication failure

因此,如果您遇到这种情况,请参阅随 EWS java Api 提供的发行说明(和/或搜索这句话以找到它们)。

请务必使用正确的 Web 服务端点和端口,因为您正在使用的套接字似乎已关闭(连接被拒绝)。这应该是这样的:

"https://YOURDOMAIN.com/EWS/Exchange.asmx"

this other StackOverflow question中提到的代码为我工作(Exchange 2010 + NTLM 身份验证方案)。

关于java - EWS Java 1.2 - 无法连接到公司 Exchange 服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16058076/

相关文章:

java - 定义shouldOverrideUrlLoading以在所需应用程序中加载URL?

java - Android-Studio:调试JNI时缺少Java日志

java - 即使在安装 Bouncy CaSTLe 提供程序后,TLSv1.2 SSLContext 也不可用错误

forms - 非 SSL 页面中的 SSL 页面 iframed - 表单提交是否仍然安全?

ios-simulator - class_getClassMethod 通常返回 nil(似乎只适用于类级别的方法)

powershell - 使用 PSSession 和 Microsoft.Exchange.Management.PowerShell.SnapIn 时出错

c# - PowerShell 参数绑定(bind)异常

java - 在java中使用new关键字访问静态资源

java - Jbox2D - body 随机移动

node.js - nodejs 中的 https 错误?