gpt4 book ai didi

java - 通过 ucwa lync 2013 发送消息

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:56:46 25 4
gpt4 key购买 nike

我正在使用这个实验性 api https://github.com/mtorak/java-lync-client连接到我们的 lync 2013 服务器。

然而它根本不起作用。我可以将该包部署到调用 web 服务的 jboss 7.1.1,但答案为空。日志显示以下内容:


12:03:23,927 INFO [stdout] (http-localhost-127.0.0.1-8080-1) REQUEST 1:<a href="https://lyncdiscover.example.com/Autodiscover/AutodiscoverService.svc/root?originalDomain=example.com" rel="noreferrer noopener nofollow">https://lyncdiscover.example.com/Autodiscover/AutodiscoverService.svc/root?originalDomain=example.com</a>
12:03:23,931 INFO [stdout] (http-localhost-127.0.0.1-8080-1) -------------------------------
12:03:23,933 INFO [stdout] (http-localhost-127.0.0.1-8080-1) ----Request Headers----
12:03:23,935 INFO [stdout] (http-localhost-127.0.0.1-8080-1) [Lorg.apache.http.Header;@123fb1a8
12:03:26,367 INFO [stdout] (http-localhost-127.0.0.1-8080-1) HTTP/1.1 403 Forbidden ( The server denied the specified Uniform Resource Locator (URL). Contact the server administrator. )
12:03:26,444 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) org.codehaus.jackson.JsonParseException: Unexpected character ('<' (code 60)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')
12:03:26,446 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at [Source: java.io.StringReader@1e196a60; line: 1, column: 2]
12:03:26,448 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.codehaus.jackson.JsonParser._constructError(JsonParser.java:1433)
12:03:26,449 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.codehaus.jackson.impl.JsonParserMinimalBase._reportError(JsonParserMinimalBase.java:521)
12:03:26,451 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.codehaus.jackson.impl.JsonParserMinimalBase._reportUnexpectedChar(JsonParserMinimalBase.java:442)
12:03:26,454 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.codehaus.jackson.impl.ReaderBasedParser._handleUnexpectedValue(ReaderBasedParser.java:1198)
12:03:26,455 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.codehaus.jackson.impl.ReaderBasedParser.nextToken(ReaderBasedParser.java:485)
12:03:26,457 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.codehaus.jackson.map.ObjectMapper._initForReading(ObjectMapper.java:2770)
12:03:26,459 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.codehaus.jackson.map.ObjectMapper._readMapAndClose(ObjectMapper.java:2718)
12:03:26,461 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.codehaus.jackson.map.ObjectMapper.readTree(ObjectMapper.java:1542)
12:03:26,462 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at com.comverse.lync.LyncClient.authenticate(LyncClient.java:537)
12:03:26,464 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at com.comverse.lync.LyncClient.createApplication(LyncClient.java:620)
12:03:26,465 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at com.comverse.lync.servlet.LyncGatewayServlet.queryPresence(LyncGatewayServlet.java:107)
12:03:26,467 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at com.comverse.lync.servlet.LyncGatewayServlet.doGet(LyncGatewayServlet.java:59)
12:03:26,469 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at javax.servlet.http.HttpServlet.service(HttpServlet.java:734)
12:03:26,471 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
12:03:26,472 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)
12:03:26,475 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
12:03:26,478 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
12:03:26,481 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
12:03:26,483 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153)
12:03:26,486 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)
12:03:26,488 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
12:03:26,490 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
12:03:26,493 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)
12:03:26,495 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
12:03:26,497 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671)
12:03:26,499 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930)
12:03:26,501 ERROR [stderr] (http-localhost-127.0.0.1-8080-1) at java.lang.Thread.run(Thread.java:744)

我查看了代码,我知道它在哪里失败了,这才是真正的开始。

在 authenticate() 方法中有以下调用。



<pre><code>LyncHttpOperationWrapper httpOpWrapper1 = doFirstRequest();
if (httpOpWrapper1 != null) {
JsonNode node;
try {
node = mapper.readTree(httpOpWrapper1.getResponseBody());
</code></pre>

似乎 doFirstRequest() 正在执行获取,但服务器拒绝它。

我试图在 firefox 中访问相同的 url,我得到了答案,我没有被拒绝。



<pre><code><resource rel="root" href="https://abs.example.com/Autodiscover/AutodiscoverService.svc/root?originalDomain=example.com">
<link rel="user" href="https://abs.example.com/Autodiscover/AutodiscoverService.svc/root/oauth/user?originalDomain=example.com"/>
<link rel="xframe" href="https://abs.example.com/Autodiscover/XFrame/XFrame.html"/>
</code></pre>

<p></p>

客户端设置如下:


private static final String LYNC_DISCOVERY_URL_KEY = "lyncDiscoveryUrl";
private static final String LYNC_DISCOVERY_URL_VALUE = "<a href="https://abs.example.com/Autodiscover/AutodiscoverService.svc/root?originalDomain=example.com" rel="noreferrer noopener nofollow">https://abs.example.com/Autodiscover/AutodiscoverService.svc/root?originalDomain=example.com</a>";



<pre><code>private static final String RESPONSE1_LINKS_SELF_HREF = "_links-self-href";
private static final String RESPONSE1_LINKS_USER_HREF = "_links-user-href";
private static final String RESPONSE1_LINKS_XFRAME_HREF = "_links-xframe-href";
private static final String RESPONSE_HEADER_WWW_AUTHENTICATE = "WWW-Authenticate";
private static final String RESPONSE_HEADER_VALUE_MSRTCOAUTH = "MsRtcOAuth";
private static final String RESPONSE_HEADER_VALUE_BEARER = "Bearer";
private static final String LYNC_EXT_POOL_HOST = "lyncextpool.example.com";
private static final String LYNC_EXT_POOL_URL = "https://lyncextpool.example.com";

private static final String X_MS_ORIGIN_HEADER_VALUE = "http://192.168.0.10";
private static final String X_MS_ORIGIN_HEADER_KEY = "X-Ms-Origin";

private static final String PROTOCOL_HTTPS = "https";
private static final String SSL_CONTEXT = "SSL";
private static final int SSL_PORT = 443;
</code></pre>

如何使用 java 从 linux 连接到 Lync 2013?

非常感谢您的提前帮助。

最佳答案

终于明白通信是怎么回事了。

问题是实际上服务器不接受 header ,因为它认为请求是外部的。

因此对于全部 5 个请求,删除 HOST 和 X_MS_ORIGIN_HEADER 允许协商,我可以访问该网页。

    httpPost.setHeader(HttpHeaders.ACCEPT, "application/json");
httpPost.setHeader(HttpHeaders.CONTENT_TYPE, "application/json");
httpPost.setHeader(HttpHeaders.AUTHORIZATION, authHeaderValue);

httpPost.setHeader(HttpHeaders.ACCEPT_ENCODING, "gzip,deflate");
httpPost.setHeader(HttpHeaders.ACCEPT_LANGUAGE, "en-US");
httpPost.setHeader(HttpHeaders.CACHE_CONTROL, "no-cache");
httpPost.setHeader(HttpHeaders.CONNECTION, "keep-alive");
//httpPost.setHeader(HttpHeaders.HOST, LYNC_EXT_POOL_HOST); <= Was the bad guy
//httpPost.setHeader(X_MS_ORIGIN_HEADER_KEY, X_MS_ORIGIN_HEADER_VALUE); <= Was the bad guy

希望这可能对其他人有所帮助。网络服务真的很有用,感谢分享。

关于java - 通过 ucwa lync 2013 发送消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25255854/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com