views:

567

answers:

1

Hello. I need the information about the SharePoint document library. Namely, I need the info whether the versioning is turned on or off and if the "require check out" option is selected. I have to use SharePoint web services.

I have looked up in Versions.asmx, Lists.asmx and SiteData.asmx, but found no method or properties that suit my needs.

Could anyone help me out please? Thanks.

+1  A: 

You will need to make use of the lists.asmx GetList method. It returns all of the metadata about a list.

Here's some code I've been using in combination with Linq to XML:

    Private _serviceRefrence As SharePointListsService.ListsSoapClient
    Dim endPoint As New ServiceModel.EndpointAddress(_serviceURL)
    Dim ListID as Guid = New Guid("<<Your List Guid>>") 

    _serviceRefrence = New SharePointListsService.ListsSoapClient("ListsSoap", endPoint)
    _serviceRefrence.ClientCredentials.Windows.ClientCredential = Credentials
    _serviceRefrence.ClientCredentials.Windows.AllowedImpersonationLevel = Security.Principal.TokenImpersonationLevel.Impersonation

    Dim results As XmlElement = _serviceRefrence.GetList(listID.ToString())
    Dim parserResults As XDocument = XDocument.Parse(results.OuterXml)

    Dim listinfo = (From list In parserResults.Descendants(XName.Get("List", "http://schemas.microsoft.com/sharepoint/soap/")) _
                    Select New With {.RequireCheckout = list.Attribute("RequireCheckout").Value, _
                                 .ModerationEnabled = list.Attribute("EnableModeration").Value, _
                                 .VersioningEnabled = list.Attribute("EnableVersioning")}).Single()

Hope this helps!

Chris Quick
Cris, thank you for your reply. Is there any way to convert this to C#? I don't understand the syntax of VB. Thanks for help.
Boris
Unfortunately, I haven't used a lot of Linq to XML in C#, so it would take me some time to figure out how to convert it. Basically, when you see a Dim, convert it as follows: ServiceModel.EndpointAddress endPoint = new ServiceModel.EnpointAddress(_serviceURL); BTW, I'm using WCF to talk to SharePoint as well.
Chris Quick