#java #exchange-server #exchangewebservices #hybrid
#java #exchange-сервер #exchangewebservices #гибрид
Вопрос:
В настоящее время мы настроили гибридную среду Exchange с помощью мастера гибридной настройки на наших тестовых серверах. Мы подумывали об использовании внешнего URL-адреса EWS (с библиотеками Java EWS) для доступа ко всей почте из локальных, а также к почтовым ящикам Exchange Online в гибридной настройке.
Фрагмент кода:
System.setProperty("https.proxyHost", "<host>");
System.setProperty("https.proxyPort", "443");
...
exchangeService.setUrl(new URI("https://<public_domain>/ews/exchange.asmx"));
exchangeService.setCredentials(new WebCredentials("ex user", "password"));
...
Ниже приведена трассировка стека:
microsoft.exchange.webservices.data.core.exception.service.remote.ServiceRequestException: The request failed. The request failed. Connect to <public domain>:443 [<public domain>/<public domain IP>] failed: Connection timed out: connect
at microsoft.exchange.webservices.data.core.request.SimpleServiceRequestBase.internalExecute(SimpleServiceRequestBase.java:74)
at microsoft.exchange.webservices.data.core.request.MultiResponseServiceRequest.execute(MultiResponseServiceRequest.java:158)
at microsoft.exchange.webservices.data.core.ExchangeService.internalFindFolders(ExchangeService.java:377)
at microsoft.exchange.webservices.data.core.ExchangeService.findFolders(ExchangeService.java:425)
at microsoft.exchange.webservices.data.core.ExchangeService.findFolders(ExchangeService.java:461)
at com.sample.externalews.UsingClientCreds.displayMailboxFolders(UsingClientCreds.java:143)
at com.sample.externalews.UsingClientCreds.usingCredentials(UsingClientCreds.java:161)
at com.sample.externalews.UsingClientCreds.main(UsingClientCreds.java:237)
Caused by: microsoft.exchange.webservices.data.core.exception.service.remote.ServiceRequestException: The request failed. Connect to <public domain>:443 [<public domain>/<public domain IP>] failed: Connection timed out: connect
at microsoft.exchange.webservices.data.core.request.ServiceRequestBase.getEwsHttpWebResponse(ServiceRequestBase.java:729)
at microsoft.exchange.webservices.data.core.request.ServiceRequestBase.validateAndEmitRequest(ServiceRequestBase.java:639)
at microsoft.exchange.webservices.data.core.request.SimpleServiceRequestBase.internalExecute(SimpleServiceRequestBase.java:62)
... 7 more
Caused by: org.apache.http.conn.HttpHostConnectException: Connect to <public domain>:443 [<public domain>/<public domain IP>] failed: Connection timed out: connect
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:156)
at org.apache.http.impl.conn.BasicHttpClientConnectionManager.connect(BasicHttpClientConnectionManager.java:313)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:393)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
at microsoft.exchange.webservices.data.core.request.HttpClientWebRequest.executeRequest(HttpClientWebRequest.java:292)
at microsoft.exchange.webservices.data.core.request.ServiceRequestBase.getEwsHttpWebResponse(ServiceRequestBase.java:720)
... 9 more
Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:96)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:380)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:236)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:218)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:183)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:403)
at java.net.Socket.connect(Socket.java:682)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:368)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)
... 19 more
microsoft.exchange.webservices.data.core.exception.service.remote.ServiceRequestException: The request failed. The request failed. Connect to <public domain>:443 [<public domain>/<public domain IP>] failed: Connection timed out: connect
at microsoft.exchange.webservices.data.core.request.SimpleServiceRequestBase.internalExecute(SimpleServiceRequestBase.java:74)
at microsoft.exchange.webservices.data.core.request.MultiResponseServiceRequest.execute(MultiResponseServiceRequest.java:158)
at microsoft.exchange.webservices.data.core.ExchangeService.bindToFolder(ExchangeService.java:504)
at microsoft.exchange.webservices.data.core.ExchangeService.bindToFolder(ExchangeService.java:523)
at microsoft.exchange.webservices.data.core.service.folder.Folder.bind(Folder.java:98)
at microsoft.exchange.webservices.data.core.service.folder.Folder.bind(Folder.java:147)
at com.sample.externalews.UsingClientCreds.displayMails(UsingClientCreds.java:171)
at com.sample.externalews.UsingClientCreds.usingCredentials(UsingClientCreds.java:163)
at com.sample.externalews.UsingClientCreds.main(UsingClientCreds.java:237)
Caused by: microsoft.exchange.webservices.data.core.exception.service.remote.ServiceRequestException: The request failed. Connect to <public domain>:443 [<public domain>/<public domain IP>] failed: Connection timed out: connect
at microsoft.exchange.webservices.data.core.request.ServiceRequestBase.getEwsHttpWebResponse(ServiceRequestBase.java:729)
at microsoft.exchange.webservices.data.core.request.ServiceRequestBase.validateAndEmitRequest(ServiceRequestBase.java:639)
at microsoft.exchange.webservices.data.core.request.SimpleServiceRequestBase.internalExecute(SimpleServiceRequestBase.java:62)
... 8 more
Caused by: org.apache.http.conn.HttpHostConnectException: Connect to <public domain>:443 [<public domain>/<public domain IP>] failed: Connection timed out: connect
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:156)
at org.apache.http.impl.conn.BasicHttpClientConnectionManager.connect(BasicHttpClientConnectionManager.java:313)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:393)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
at microsoft.exchange.webservices.data.core.request.HttpClientWebRequest.executeRequest(HttpClientWebRequest.java:292)
at microsoft.exchange.webservices.data.core.request.ServiceRequestBase.getEwsHttpWebResponse(ServiceRequestBase.java:720)
... 10 more
Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:96)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:380)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:236)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:218)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:183)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:403)
at java.net.Socket.connect(Socket.java:682)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:368)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)
... 20 more
Когда мы используем конечную точку Exchange EWS https://outlook.office365.com/EWS/Exchange.asmx , мы можем получить доступ к письмам только от пользователя Exchange Online, и он выдает ошибку «Почтовый ящик не существует» для локального пользователя Exchange, что, я полагаю, ожидаемо.
Пожалуйста, сообщите нам, возможно ли это, т.Е. Можем ли мы использовать внешнюю конечную точку EWS для доступа как к локальным, так и к сетевым почтовым ящикам Exchange. Если нет, есть ли какой-либо другой способ, которым это может быть достигнуто?
Ответ №1:
Нет для пользователей OnPrem Exchange (в гибридном режиме) вы должны использовать конечную точку OnPrem EWS, вы можете использовать конечную точку Autodiscoverv2 (которая не аутентифицирована), чтобы определить правильную конечную точку, которую вы должны использовать. например
https://outlook.office365.com/autodiscover/autodiscover.json?Email=user@domain.comamp;Protocol=ews
Если вы настроите гибридную современную аутентификацию, вы можете получить токен аутентификации от Azure, который затем сможете использовать на сервере OnPrem.