我正在尝试使用此代码来获取网站集中的更改。但我不知道如何获取databaseId。

            SiteData.SiteData siteData = new SiteData.SiteData();
            siteData.UseDefaultCredentials = true;
            siteData.Url = "http://localhost:333/_vti_bin/sitedata.asmx";
            string lastChangeID = String.Empty;
            string result = siteData.GetContent(SiteData.ObjectType.SiteCollection, "", "", "", false, false, ref lastChangeID);
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(result);
            string startChangeId = string.Empty;
            string endChangeId = doc.ChildNodes[0].ChildNodes[0].Attributes["ChangeId"].Value;
            bool moreChanges;
            string databaseId = "";
            string result2 = siteData.GetChanges(SiteData.ObjectType.SiteCollection, databaseId, ref startChangeId, ref endChangeId, 5, out moreChanges);
            MessageBox.Show(result2);


感谢您的时间。

编辑:
这是GetContent结果:

最佳答案

您不需要数据库ID即可在SiteCollection范围内调用“ GetChanges”方法。我使用“ GetChangesEx”,并且效果很好,此方法返回的信息类似于“ GetChanges”。检查协议规范(PDF)以查看不同之处:Site Data protocol specification。另外,我认为您的“ SoapServerException”问题与我在这里的问题相同:other question

这个代码示例是我提到的另一个问题,但是为了更好的可读性,我将其发布在这里:

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 xmlInput = "<GetChanges>" +
                  "<ObjectType>7</ObjectType>" +
                  "<ContentDatabaseId/>" +
                  "<StartChangeId>1;1;69b025ce-96a7-4131-adc0-7da1603e8d24;634439727021700000;47404</StartChangeId>" +
                  "<EndChangeId>1;1;69b025ce-96a7-4131-adc0-7da1603e8d24;634441802456970000;47472</EndChangeId>" +
                  "<RequestLoad>100</RequestLoad>" +
                  "<GetMetadata>False</GetMetadata>" +
                  "<IgnoreSecurityIfInherit>True</IgnoreSecurityIfInherit>" +
                  "</GetChanges>";
String result = siteDataService.GetChangesEx(1, xmlInput);

关于c# - 在Sharepoint SiteData Web服务中使用GetChanges,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/6408275/

10-10 19:53