0

I'm currently trying to connect to our company's Exchange server using the EWS Java API. Unfortunately when try to execute anything (either autodiscover or some other action after using setUrl manually) I receive the following error:

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

I tried logging in using my credentials to the exchange servers web interface and this is working fine. Assuming it might be related to SSL issues, I also tried implementing a dummy TrustManager and setting it as default for HttpsUrlConnections.

Unfortunately this didn't help and the error still persists.

One notable fact: In my Outlook I can see that the Exchange server is configured to use a proxy server and a specific SSL URL to connect to it. (Proxy authentication is set to NTLM) I'm not quite sure how to reflect this in my coding.

Might this be causing the exception or am I looking at a different issue here?

4

1 回答 1

0

Java EWS API 的发行说明提到:

在 Windows 7 操作系统(32 位)上运行时,如果应用程序生成以下错误:错误:请求失败。无法获取响应代码java.io.IOException:身份验证失败

因此,如果这是您的情况,请参阅 EWS java Api 提供的发行说明(和/或 gooole 这个确切的句子以找到它们)。

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

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

这个其他 StackOverflow 问题中提到的代码对我有用(Exchange 2010 + NTLM 身份验证方案)。

于 2013-04-22T14:54:55.707 回答