我正在使用此实验性api https://github.com/mtorak/java-lync-client来连接到我们的lync 2013服务器。
然而它根本不起作用。我可以将软件包部署到jboss 7.1.1调用webservice,但答案是null。日志显示以下内容:
12:03:23,927 INFO [stdout] (http-localhost-127.0.0.1-8080-1) REQUEST 1:https://lyncdiscover.example.com/Autodiscover/AutodiscoverService.svc/root?originalDomain=example.com
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()方法中有以下调用。
LyncHttpOperationWrapper httpOpWrapper1 = doFirstRequest();
if (httpOpWrapper1 != null) {
JsonNode node;
try {
node = mapper.readTree(httpOpWrapper1.getResponseBody());
LyncHttpOperationWrapper httpOpWrapper1 = doFirstRequest();
if (httpOpWrapper1 != null) {
JsonNode node;
try {
node = mapper.readTree(httpOpWrapper1.getResponseBody());
似乎doFirstRequest()正在执行get,但服务器拒绝它。
我试图在Firefox中访问相同的网址,我得到了答案,我没有被拒绝。
<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"/>
客户端设置如下:
<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"/>
private static final String LYNC_DISCOVERY_URL_KEY = "lyncDiscoveryUrl";
private static final String LYNC_DISCOVERY_URL_VALUE = "https://abs.example.com/Autodiscover/AutodiscoverService.svc/root?originalDomain=example.com";
如何从linux,java连接到Lync 2013?
非常感谢您的帮助。
答案 0 :(得分:1)
我终于明白了沟通的内容。
问题是实际上服务器没有接受标题,因为它认为请求是外部的。
因此,对于整个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
希望这可能有助于其他人。 Web服务非常有用,感谢分享。