SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to use this code to get changes in a site collection. But i don't know how to get the 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();
            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);

Thank you for your time.

share|improve this question
up vote 1 down vote accepted

You don't need the database Id for calling "GetChanges" method on SiteCollection scope. I use "GetChangesEx" and it works well, this method returns similar information to "GetChanges". Check the protocol specification (PDF) to see the differences: Site Data protocol specification. Also, I think your problem with the "SoapServerException" is the same I had here: other question.

This code example is on the other question I mentioned, but I'll post it here for better readability:

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>" + 
String result = siteDataService.GetChangesEx(1, xmlInput);
share|improve this answer
Thanks alot! I used GetChangesEx() instead of GetChanges() like you described and it worked. – user3470 Jun 22 '11 at 7:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.