gpt4 book ai didi

android - 如何使用 android 更新 Sharepoint 2010 列表项?

转载 作者:行者123 更新时间:2023-11-30 02:32:17 25 4
gpt4 key购买 nike

我正在为 android 开发一个 sharepoint2010 应用程序。我想使用以下代码更新 Sharepoint 2010 ListItem:

private void updateListItem() {

String serviceUrl = "http://IP_address/_vti_bin/Lists.asmx";
HttpClient httpclient = new DefaultHttpClient();
((AbstractHttpClient) httpclient).getAuthSchemes().register("ntlm",
new NTLMSchemeFactory());
NTCredentials creds = new NTCredentials("username", "password", "55",
"demo");
((AbstractHttpClient) httpclient).getCredentialsProvider()
.setCredentials(AuthScope.ANY, creds);
try {
HttpConnectionParams.setConnectionTimeout(httpclient.getParams(),
120000);

HttpPost httppost = new HttpPost(serviceUrl);
StringEntity se;
String str1 ="<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><soap:Body>"
+ "<UpdateListItems xmlns=\"http://schemas.microsoft.com/sharepoint/soap/\">"
+ "<listName>"
+ "{DF1398C7-EF73-485E-913E-5F5896D6DF22}"
+ "</listName>"
+ "<updates>"
+ "<Batch OnError='Continue' ListVersion='1'>"
+ "<Method ID='1' Cmd='New'>"
+ "<Field Name='Title'>View</Field>"
+ "<Field Name='Resource'>7;#A Kr Singh</Field>"
+ "<Field Name='Project'>13;#Microsoft- SharePoint based Employee Portal</Field>"
+ "<Field Name='Task'>1;#Accounting</Field>"
+ "<Field Name='Date'>2014-11-21 11:15:50</Field>"
+ "</Method>"
+ "</Batch>"
+ "</updates>"
+ "</UpdateListItems>"
+ "</soap:Body>" + "</soap:Envelope>";
se = new StringEntity(String.format(str1, HTTP.UTF_8));

se.setContentType("text/xml");
httppost.setEntity(se);

HttpResponse httpresponse = httpclient.execute(httppost);
InputStream in = httpresponse.getEntity().getContent();
String str = inputStreamToString(in).toString();

readSoap(str);

} catch (Exception e) {

e.printStackTrace();
}
}

但是报错

soap:ServerException of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown.The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again.0x8102006d

请给我任何解决方案。
或者给我任何其他使用 android 更新 SharepointListItem 的方法。

最佳答案

嗨,经过一些重新教学,我在请求 header 中添加以下操作时找到了解决方案。

httppost.setHeader("SOAPAction", “http://schemas.microsoft.com/sharepoint/soap/UpdateListItems”);之后工作正常。

关于android - 如何使用 android 更新 Sharepoint 2010 列表项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27151034/

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