Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在java中获取sharepoint项目的listItemId值_Java_Sharepoint - Fatal编程技术网

如何在java中获取sharepoint项目的listItemId值

如何在java中获取sharepoint项目的listItemId值,java,sharepoint,Java,Sharepoint,我正在尝试使用java中sharepoint的ListsSoap web服务来获取当前位于sharepoint上的docx文件的附件。并尝试将docx文件下载到本地磁盘。但是,现在我在以下代码中尝试从sharepoint获取XML时出错 我得到了错误 引发了类型为“Microsoft.SharePoint.SoapServer.SoapServerException”的异常 SharepointReference sharepointReference = new SharepointRefer

我正在尝试使用java中sharepoint的ListsSoap web服务来获取当前位于sharepoint上的docx文件的附件。并尝试将docx文件下载到本地磁盘。但是,现在我在以下代码中尝试从sharepoint获取XML时出错

我得到了错误 引发了类型为“Microsoft.SharePoint.SoapServer.SoapServerException”的异常

SharepointReference sharepointReference = new SharepointReference();
ListsSoap listsSoap = sharepointReference.getListAuth("sharepointId","sharepointPassword");
GetAttachmentCollectionResponse.GetAttachmentCollectionResult x = listsSoap.getAttachmentCollection("listName", "28");
参数中的28表示listitems的ows_ID列的值。我不确定这是否是getAttachmentCollection的第二个参数获取的列表项的listItemId


有人知道错误是由于某种身份验证问题还是由于listItemId无效而引发的吗?

在SharepointReference类及其getListAuth方法中隐藏了设置和身份验证的逻辑。由于不知道逻辑,我们无法确定原因。下面的逻辑是通过web服务访问SharePoint列表内容的典型方法。你可能想试试这个。这不是编译就绪,因为我从我的解决方案中借用了一些片段,由于IP原因,我无法共享这些片段

这是我们的SPAuthenticator.java类

public class SPAuthenticator extends Authenticator {

    public PasswordAuthentication getPasswordAuthentication() {
        return new PasswordAuthentication("domain\username","password".toCharArray());
    }
}

希望这有帮助

虽然发布的代码可能有助于OP,但您没有回答原始问题。那么,为什么OP的方法不起作用?你做了什么来克服这个问题?请再解释一下。@honk我应该在回答之前解释清楚。SharepointReference对象和getListAuth方法不是SharePoint web services的一部分。我的目标是在构造函数和/或getListAuth方法中屏蔽实际逻辑。上面的代码片段应该是他的方法应该使用的逻辑。感谢您的回复。您可以随时编辑您的答案。请在答案中直接添加您的解释,以改进它。你的答案越完整,你的答案被否决的概率就越高。
public class SPAuthenticator extends Authenticator {

    public PasswordAuthentication getPasswordAuthentication() {
        return new PasswordAuthentication("domain\username","password".toCharArray());
    }
}