简体   繁体   English

EWS Java 1.2-无法连接到公司Exchange Server

[英]EWS Java 1.2 - Unable to connect to company Exchange Server

I'm currently trying to connect to our company's Exchange server using the EWS Java API. 我目前正在尝试使用EWS Java API连接到我们公司的Exchange服务器。 Unfortunately when try to execute anything (either autodiscover or some other action after using setUrl manually) I receive the following error: 不幸的是,当尝试执行任何操作(手动使用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

I tried logging in using my credentials to the exchange servers web interface and this is working fine. 我尝试使用我的凭据登录到交换服务器Web界面,并且工作正常。 Assuming it might be related to SSL issues, I also tried implementing a dummy TrustManager and setting it as default for HttpsUrlConnections . 假设它可能与SSL问题有关,我还尝试实现了一个虚拟TrustManager并将其设置为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. 一个值得注意的事实:在Outlook中,我可以看到Exchange服务器已配置为使用代理服务器和特定的SSL URL与其连接。 (Proxy authentication is set to NTLM) I'm not quite sure how to reflect this in my coding. (代理身份验证设置为NTLM)我不太确定如何在我的编码中反映出来。

Might this be causing the exception or am I looking at a different issue here? 可能是造成异常的原因,还是我在这里查看其他问题?

The releases notes of Java EWS API mentions: Java EWS API的发行说明中提到:

While running on Windows 7 OS, 32-bit, and if the application generates the following error : ERROR : Request failed. 在Windows 7 OS(32位)上运行时,如果应用程序生成以下错误:ERROR:请求失败。 Unable to get response codejava.io.IOException: Authentication failure 无法获取响应代码java.io.IOException:身份验证失败

So if this is your case, refer to the release notes provided with EWS java Api (and/or gooole this exact sentence to find them back). 因此,如果您遇到这种情况,请参阅EWS java Api随附的发行说明(和/或将此确切句子拼写为找到它们)。

Be sure to use the correct Web Service end point and port because it seems that the socket you are using is closed (connection refused). 确保使用正确的Web服务端点和端口,因为您正在使用的套接字似乎已关闭(连接被拒绝)。 This should be like this: 应该是这样的:

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

The code mentionned in this other StackOverflow question worked for me (Exchange 2010 + NTLM Authentication Scheme). 另一个StackOverflow问题中提到的代码对我有用 (Exchange 2010 + NTLM身份验证方案)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM