【发布时间】:2011-06-16 21:52:17
【问题描述】:
我正在尝试从 Java 应用程序运行 GetChanges 方法 (sitedata.asmx)。但是我无法弄清楚我必须传递的正确参数。这是针对 SharePoint 2010 的。
通过查看service protocol specification,我看到这是必需的参数:
objectType:变化跟踪空间 报告,要么 “内容数据库”或“站点集合”。 所有其他 objectType 值,如 在第 2.2.5.3 节中定义,不得 使用。请注意,“网站”在 实际上这个参数的上下文 表示网站集。
contentDatabaseId:内容的 GUID 数据库,预先知道或获得 由 GetContent 请求。
LastChangeId: 指定起点的标记 请求的更改报告。 通常协议客户端获取 此值来自对 a 的响应 以前的 GetContent 或 GetChanges 操作。
CurrentChangeId: 一个令牌指定 请求更改的端点 报告。如果不为空,CurrentChangeId 必须是从获得的有效令牌 对先前 GetChanges 的响应 手术。通常,这个元素是 空的;空指定 协议客户端请求所有更改 从起点开始到 现在的时间。
超时:一个值 这决定了多少变化 应该在当前获取 手术。此值必须更大 大于 0 并且协议服务器必须 仅获取 x% 的总更改 默认获取,其中 x 是 (超时除以 30000)。
协议客户端必须传递令牌 对应变化跟踪 由 objectType 指定的空间和 SOAP 请求的目标 URL。
我发送的 SOAP In 消息如下:
<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Body>
<ns1:GetChanges xmlns:ns1="http://schemas.microsoft.com/sharepoint/soap/">
<ns1:objectType>SiteCollection</ns1:objectType>
<ns1:contentDatabaseId>E5C5E20A-5A9F-406C-B9F6-28923750CECD</ns1:contentDatabaseId>
<ns1:startChangeId>1;0;E5C5E20A-5A9F-406C-B9F6-28923750CECD;634438121498470000;46852</ns1:startChangeId>
<ns1:Timeout>0</ns1:Timeout>
</ns1:GetChanges>
</soapenv:Body>
</soapenv:Envelope>
但是我得到了这样的回应:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<soap:Fault>
<soap:Code>
<soap:Value>soap:Receiver</soap:Value>
</soap:Code>
<soap:Reason>
<soap:Text xml:lang="en">Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown.</soap:Text>
</soap:Reason>
<detail>
<errorstring xmlns="http://schemas.microsoft.com/sharepoint/soap/">Object reference not set to an instance of an object.</errorstring>
</detail>
</soap:Fault>
</soap:Body>
</soap:Envelope>
检查了来自 SharePoint 的日志(位于 Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\LOGS),发现以下异常:
SOAP exception: System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.SharePoint.SPChangeToken.ParseChangeToken(String strChangeToken)
at Microsoft.SharePoint.SPChangeToken..ctor(String strChangeToken)
at Microsoft.SharePoint.SoapServer.SiteDataImpl.GetChanges(ObjectType objectType, String contentDatabaseId, String& startChangeId, String& endChangeId, Int64 maxChangesToFetch, UInt32 maxSPRequests, Boolean getMetadata, Boolean ignoreSecurityIfInherit, Int32 schemaVersion, Boolean& moreChanges)
at Microsoft.SharePoint.SoapServer.SiteDataImpl.GetChanges(ObjectType objectType, String contentDatabaseId, String& startChangeId, String& endChangeId, Int32 Timeout, Boolean& moreChanges)
at Microsoft.SharePoint.SoapServer.SiteData.GetChanges(ObjectType objectType, String contentDatabaseId, String& LastChangeId, String& CurrentChangeId, Int32 Timeout, Boolean& moreChanges)
但是,我找不到对该错误的任何引用。我什至无法从 SPChangeToken 类 (http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spchangetoken_methods.aspx) 中找到 ParseChangeToken 方法,所以这很混乱。
我已经看到了这个问题,但这并不能解决我的问题:Other question
谁能帮我正确调用这个网络服务?
编辑
尝试从 C# 应用程序调用它以确定问题不在于 Java。这是代码:
SiteData.SiteDataSoapClient siteDataService = new SiteData.SiteDataSoapClient();
siteDataService.Endpoint.Address = new System.ServiceModel.EndpointAddress("URL/_vti_bin/sitedata.asmx");
siteDataService.ClientCredentials.Windows.ClientCredential = new System.Net.NetworkCredential("username", "password", "domain");
siteDataService.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
String startChangeId = "1;1;69d025ce-96a7-4131-adc0-7da1603e8d24;634439002539570000;46914";
String endChangeId = "";
bool hasMoreChanges = false;
String databaseID = E5C5E20A-5A9F-406C-B9F6-28923750CECD; //Got it by querying SharePoint database. Any idea how to get it programatically?
String result = siteDataService.GetChanges(SiteData.ObjectType.SiteCollection, databaseID, ref startChangeId, ref endChangeId, 0, out hasMoreChanges);
return result;
但是,我得到了“Microsoft.SharePoint.SoapServer.SoapServerException”,并且此异常的详细信息为空。使用Fiddler 窥探 SharePoint 服务器返回的 XML,并发现相同的“对象引用未设置为对象实例”异常。
所以这肯定意味着我传递的参数有问题,对吧?
谢谢!!
编辑
如果有人感兴趣,我也通过在 XML 消息中将 StartChangeId 设置为 LastChangeId 并将 EndChangeId 设置为 CurrentChangeId 来完成这项工作。
【问题讨论】:
标签: c# java web-services sharepoint-2010 sharepoint-2007