Sometimes when you build a large Internet facing site you need to push or pull content to or from other systems. It could be that you are working with external content providers who will provide for instance daily news articles. Or maybe you have to send out e-mail campaigns and you would like to pull content from your site into your newsletters. In these cases you might wonder if it is possible to use for instance the new RESTful services which uses HTTP to get or send information to your pages libraries.In this article I will perform a small POC to see if that is possible and what the alternatives are.The ListData.svc WCF web serviceThe ListData.svc web service did not exist with SharePoint 2007. You can access it through the _vti_bin virtual directoy like: http://www.company.com/en-us/news/_vti_bin/ListData.svcSo what does it provide:It provides an ATOM feed of all the lists and links to URL’s that provide more data. As you can see below it will show you for instance a list of collections. The pages library would be one of them. Now, if you would attach the HFRD attribute to your query it would give you access to all of the content within the pages library. Next to that you can Query the content by appending your query to the URL, including filtering, sorting and paging. An example would be something like:http://.../_vti_bin/ListData.svc/Pages?$filter=(Country eq 'Netherlands') But that is not all! You can actually add, delete or update content. So if your HTTP Header contains the verb DELETE you could delete the second item by calling the same URL but then with:http://.../_vti_bin/ListData.svc/Pages(1)And even better, caching and security has been taken care of as well.And if you use ASP.NET Ajax 4 you can query WCF Data Services like the ListData.svc natively and it will give you the benefit of using templates.Publishing page returned by ListDataNow, what about the information you get back from the ListData.svc when querying a pages library?Imagine you content type is called Company News and is inheriting from the out of the box content type article page.If you would query the page through the ListData web service it would give you either the ATOM XML feed or the JSON data feed (depends on your type of request).Have a look at the columns below. As you can see some of the columns are “system” columns like Content Type ID, some of the are from the article page like “Page Content” and some are defined by yourself like “Publisher”.ContentTypeID0x01000C568D50A14D9……NameMyNews.aspxTitleCompany X has announced new campaignPageLayouthttp://www.company.com/_catalogs/masterpage/mynewslayout.aspxPublisherReutersPage ContentToday it was announced that Company X has …..Not everything will be returnedYou have probably already noticed that Page Content as shown in the table above, has been removed and colored red. To me it was a little surprise that it was not being returned by the ListData web service. After doing some tests I discovered that:Site columns of type Publishing HTML are not returned by ListDataSite columns of type Publishing Image are not returned by ListDatapossibly more columns are being omitted (haven’t checked all of them yet) that are publishing specificCan I use ListData with Publishing pagesThe answer is probably: Yes in a limited way. As you don’t have the ability to change for instance the Page Content, you could still update the list item fields like the Title, Publishing Date, or custom fields like the Number of Times Read and so forth. It depends if you have need for that. To give you a real world example: if you would to add something like “Did this article answer your question” you could add a counter to your article called “Usefulness” and increase that by one if someone clicks on a button “yes”, entirely through Javascript by calling the ListData web service.Are there alternatives?CMIS: CMIS stands for Content Management Interoperability Specification. It is an "interoperability specification for interacting with document-centric content repositories via HTTP-based protocols.".It is a new standard driven by Alfresco, Day, EMC, Fatwire, IBM, Microsoft and Open Text.Now, Microsoft has released a connector for CMIS for SharePoint 2010. Is it important? Yes! As we can more easily integrate SharePoint 2010 with other systems through an official standard. This comes with the connector:· A CMIS Producer for SharePoint that makes SharePoint lists and document libraries available to other systems using the CMIS interfaces.· A CMIS Consumer Web Part, enabling content from other CMIS supported repositories to be displayed and edited within SharePoint. The downside is that CMIS does not support WCM in its first release.Client side object model: this does not support Publishing webs to create a pageListItemCollection.asmx: this would allow you to create a content type with Publishing HTML site columns but you cannot get Rich markup across the wire.Your own custom wrapper. It would basically mean that you create your own web service that allows for pushing content into SharePoint and your code would take care of creating the publishing page.Your own code could be something like this:SPSite site = new SPSite(Properties.Settings.Default.rootSiteUrl + Properties.Settings.Default.targetURL);SPWeb web = site.OpenWeb();PublishingWeb pubWeb = PublishingWeb.GetPublishingWeb(web);PublishingPage newPubPage = pubWeb.GetPublishingPages().Add(pageName, GetPageLayout());SPListItem newPage = newPubPage.ListItem;SPList PagesLibrary = newPage.ParentList;newPage["Title"] = pageTitle;newPage["Page Content"] = Microsoft.SharePoint.Utilities.SPEncode.HtmlDecode(pageContent);newPage["Article Date"] = articleDate;newPage.Update();newPage.File.CheckIn("");newPage.File.Publish("Published on creation");newPage.File.Approve("Approved on creation");SummaryWorking with SharePoint 2010 Publishing Pages through the ListData.svc is very limited, hence could be useful in some cases. Most of the publishing related site columns are not being returned by the web service. Other methods fail for the same reason. It looks like a custom web service is the only solution.Any feedback or working solution is appreciated!


Discuss   Add this link to...  Bury

Comments Who Voted Related Links