Commerce Foundation SharePoint List Integration

A SharePoint list is a custom or out-of-the-box list provided by SharePoint that allows you to customize, by adding and removing columns, and creating views. The list is managed within the SharePoint management interface. In a SharePoint site, you can create SharePoint sites and use the ContentQuery Web Part to retrieve data from a list and display it on the screen. In a non-SharePoint site, this data would typically be unavailable. SharePoint list support makes this data available and enables relationships with other commerce entity data in a transparent way to any channels in the solution. Mapping a SharePoint list to a Commerce Entity allows the use of SharePoint lists for additional site content such as ratings and provides a mechanism for retrieving that data from sites running without SharePoint or channels where SharePoint is not available.

The SharepointListItemProcessor operations sequence component allows the user to connect to a SharePoint system, retrieve list elements and return them as a CommerceEntity. When you use this component in a 3-tier deployment scenario:

  1. the presentation tier residing inside SharePoint will call the application tier which will call the presentation tier hosted by SharePoint

  2. the application tier will then translate the result and forward it to the presentation tier

From a security perspective, this means that a double thrust must exist between the presentation and tier perspective.

From a performance perspective, many tier boundaries are being crossed. Please keep these security and performance considerations in mind before you decide to use this component.

We can also note that our current solution is not using this component anymore due to those concerns. We instead directly call the lists with the SharePoint API.

Functionally, SharePoint lists behave as commerce entities derived from other sources. The primary difference that will be noticed is that SharePoint uses CAML queries to query a list instead of SQL-based queries. The following shows a query operation:

string ListItemId = "1";
CommerceQuery<CommerceEntity> queryRequest = new CommerceQuery<CommerceEntity>("spAnnouncements");

            //Specify fields to return
            queryRequest.Model.Properties.Add("Title");
            queryRequest.Model.Properties.Add("Body");

//Specify the search criteria 
            queryRequest.SearchCriteria.WhereClause = @"<Where><Eq><FieldRef Name='ID' /><Value Type='Counter'>" 
+ ListItemId + "</Value></Eq></Where>";

Note

The SearchCriteria.WhereClause is a CAML (XML based expression) query.

Model

You can modify this commerce entity, as required. This model, taken from the out-of-the-box site, is provided as an example. Note that this is a representative example of a single SharePoint list mapping (Announcements). This entry would have to be repeated for each list that is mapped. The individual configuration elements (Server, Site, Port, ListName, ViewName) are configured for each list. This provides the capability of mapping to lists from different sites within the same server or completely different SharePoint servers. These properties are present to provide Metadata about the list itself and will not be returned as individual properties within the list.

<CommerceEntity name="spAnnouncements">
   <DisplayName value="Announcements" />
   <Description value="Maps to Sharepoint Announcements list" />
   <Authorization>
      <Operation name="Query" >
         <Claimset name="Everyone"/>
      </Operation>
      <Operation name="Create" >
         <Claimset name="Everyone"/>
      </Operation>
      <Operation name="Update" >
         <Claimset name="Everyone"/>
      </Operation>
      <Operation name="Delete" >
         <Claimset name="Everyone"/>
      </Operation>
   </Authorization>
   <Properties>
      <Property name="ID" dataType="String" />
      <Property name="Title" dataType="String">
         <DisplayName value="Title"/>
         <Description value="The Title of the Announcement." />
      </Property>
      <Property name="Body" dataType="String">
         <DisplayName value="Body"/>
         <Description value="The Body of the Announcement." />
      </Property>
      <Property name="Expires" dataType="Date">
         <DisplayName value="Expires"/>
         <Description value="Expiration date and time." />
      </Property>
   </Properties>
</CommerceEntity>

All SharePoint List connection parameters are set in the channel configuration file as shown in the following example.

   <Configuration customElementName="SharepointListItemConfiguration"
                    customElementType="Microsoft.Commerce.SequenceComponents.Extensions.Components.SharepointListItemElement, Microsoft.Commerce.SequenceComponents.Extensions, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
      <SharepointListItemConfiguration
              SPSiteUrl="https://localhost:7777/"
              ListId="{CA62D447-F0D2-4B37-8CF8-68111940DDE8}"      
              ActiveView="" />
    </Configuration>

Operation Sequence Components

Component

Description

SharepointListItemProcessor

This processes SharePoint list items.

Enabling SharePoint List Integration

Unless you have a valid endpoint address specified, Microsoft Multi-Channel Commerce Foundation will throw an exception. To enable this feature you must perform the following tasks.

Add an endpoint in Web.config

In the Web.config file, add the endpoint configuration entry corresponding to a SharePoint List service, for example:

<endpoint address="https://localhost:13653/_vti_bin/lists.asmx"

binding="basicHttpBinding" bindingConfiguration="ListsSoap"

contract="SharepointListService.ListsSoap" name="ListsSoap" />

Add references in MetadataDefinitions.xml

In your MetadataDefinitions.xml file, add references to any required commerce entities used by SharePoint Lists as shown in the Model section of this document.

See Also

Other Resources

SharepointListItemProcessor