【问题标题】:Java - How to connect to Microsoft Office 365 SharePointJava - 如何连接到 Microsoft Office 365 SharePoint
【发布时间】:2013-10-30 16:52:55
【问题描述】:

我需要通过公司防火墙连接到 Office 365 上的 SharePoint 2010 实例。我尝试使用 java-sharepoint-library

NtlmAuthenticator credentials = new NtlmAuthenticator(
    "myactivedirectorydomain", "myusername", "mypassword"); 

HttpProxy httpProxy = new HttpProxy("proxy.ourcompany.com", 80);

SPSite site = new SPSite(
    new URL("https://ourcompany.com/sites/teams_MySandbox"), 
    credentials, 
    httpProxy, 
    true, 
    SPVersion.SP2010);

SPWeb rootWeb = site.getRootWeb(); //gives error below

这是我得到的错误:“服务器重定向太多次 (20)”

javax.xml.ws.WebServiceException: java.net.ProtocolException: Server redirected too many  times (20)
    at com.sun.xml.internal.ws.transport.http.client.HttpClientTransport.readResponseCodeAndMessage(Unknown Source)
    at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.createResponsePacket(Unknown Source)
    at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.process(Unknown Source)
    at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.processRequest(Unknown Source)
    at com.sun.xml.internal.ws.transport.DeferredTransportPipe.processRequest(Unknown Source)
    at com.sun.xml.internal.ws.api.pipe.Fiber.__doRun(Unknown Source)
    at com.sun.xml.internal.ws.api.pipe.Fiber._doRun(Unknown Source)
    at com.sun.xml.internal.ws.api.pipe.Fiber.doRun(Unknown Source)
    at com.sun.xml.internal.ws.api.pipe.Fiber.runSync(Unknown Source)
    at com.sun.xml.internal.ws.client.Stub.process(Unknown Source)
    at com.sun.xml.internal.ws.client.sei.SEIStub.doProcess(Unknown Source)
    at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(Unknown Source)
    at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(Unknown Source)
    at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(Unknown Source)
    at com.sun.proxy.$Proxy38.getWeb(Unknown Source)
    at org.korecky.sharepoint.SPSite.getRootWeb(SPSite.java:280)
    at com.dupont.cintell.test4.TestSharePointConnection.testConnect(TestSharePointConnection.java:87)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.net.ProtocolException: Server redirected too many  times (20)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
    at java.net.HttpURLConnection.getResponseCode(Unknown Source)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(Unknown Source)
    ... 44 more

感谢您的帮助!

【问题讨论】:

    标签: java sharepoint sharepoint-2010 office365


    【解决方案1】:

    我可能错了,但我认为您遇到了 Sharepoint Loopback 检查问题:

    http://www.jeremytaylor.net/2010/05/24/sharepoint-disable-loopback-check-disableloopbackcheck-dword-in-registry/

    尝试其中一种解决方法,注意关闭它所涉及的安全问题。

    我会暂时禁用它,只是为了检查它是否确实是问题所在。

    【讨论】:

    • 谢谢,但服务器位于 Microsoft Office 365 云中。我无法在该服务器上进行注册表更改。应该可以使用 Java 与这样的服务器进行通信,因为我可以使用 MS Office 客户端(Access、Excel)与服务器进行通信。
    • 您使用的是什么代理? NTLM 不太喜欢代理,有没有可以在 java 客户端设置的 keep alive 属性?
    • 嘿,谢谢,我正在使用常规 Java HTTP/HTTPS 代理。
    • 这篇最近的帖子看起来很有帮助:blog.ashwani.co.in/blog/2013-07-28/… 看起来 java-sharepoint-library 不可靠。会尝试这种方法。谢谢!
    猜你喜欢
    • 1970-01-01
    • 2011-07-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-07
    • 2018-06-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多