Lists.GetListContentType Method
Windows SharePoint Services 3
Returns the content type definition schema for the specified list content type.
Web Service: ListsWeb Reference: http://<Site>/_vti_bin/Lists.asmx
Lists Members
Lists Web Service
Content Type IDs
[SoapDocumentMethodAttribute("http://schemas.microsoft.com/sharepoint/soap/GetListContentType", RequestNamespace="http://schemas.microsoft.com/sharepoint/soap/", ResponseNamespace="http://schemas.microsoft.com/sharepoint/soap/", Use=SoapBindingUse.Literal, ParameterStyle=SoapParameterStyle.Wrapped)] public XmlNode GetListContentType ( string listName, string contentTypeId )
Parameters
- listName
A string representing the name of the list that contains the list content type.
- contentTypeId
A string containing the content type ID of the list content type.
Return Value
An XML fragment in the form of a ContentType element that can be assigned to a System.Xml.XmlNode object. The following example return value is edited for clarity.<ContentType ID="0x010100C78DE4D7C0C57C43AF878D28256599CA" Name="NewContentType" Group="Custom Content Types" Description="Create a new document." Version="1" xmlns="http://schemas.microsoft.com/sharepoint/soap/"> <Folder TargetName="Forms/NewContentType" /> <Fields> ... <DocumentTemplate TargetName="Forms/NewContentType/template.doc" /> <XmlDocuments> ... </XmlDocuments> </ContentType>
The content type definition is the same as would be returned by invoking the SchemaXml method.
The following example retrieves the content type definition for the specified list content type, and saves it as an XML file.
Imports System.Xml Imports System.Web.Services.Protocols Public Sub GetOneListContentType() Dim listService As New Web_Reference_Folder.Lists listService.Credentials = System.Net.CredentialCache.DefaultCredentials Dim listName As String = "listName" Dim contentTypeId As String = "0x010100C78DE4D7C0C57C43AF878D28256599CA002E1A80DF76000C4780E09DDFFB90076D" 'Retrieve site content type data from Web service. Try Dim myNode As XmlNode = listService.GetListContentType(listName, contentTypeId) 'Create XML document. Dim XmlDoc As New XmlDocument Dim d As XmlNode d = XmlDoc.CreateXmlDeclaration("1.0", "", "yes") XmlDoc.AppendChild(d) 'Move Web service data into XML document and save. Dim root As XmlNode = XmlDoc.CreateElement("ContentTypes") root.InnerXml = myNode.OuterXml XmlDoc.AppendChild(root) XmlDoc.Save("SingleListContentType.xml") Catch ex As SoapException MessageBox.Show("Message:" + ControlChars.Lf + ex.Message & _ ControlChars.Lf & _ "Detail:" + ControlChars.Lf + ex.Detail.InnerText & _ ControlChars.Lf & _ "StackTrace:" & ControlChars.Lf + ex.StackTrace) Catch ex As Exception MessageBox.Show(ex.Message.ToString) End Try End Sub
Reference
Lists ClassLists Members
Lists Web Service
Other Resources
Content TypesContent Type IDs