Dotnetdreamer's Weblog

SharePoint, Silverlight and Azure

Posts Tagged ‘MOSS’

MOSS Web Services – Accessing Sharepoint List data

Posted by Ramprasad Navaneethakrishnan on June 4, 2009

Sharepoint 2007 provides rich set of API’s that allows developers to develop custom components in Sharepoint to meet custom requirements.

SharePoint API’s can be classified into two types.

  1. Sharepoint Object Model
  2. Sharepoint Web Services

Sharepoint Object Model enables developers to customize almost anything that is in Sharepoint right from creating a Site Collection to connecting to external data sources. This object model is enclosed in 10 dll’s with 30 namespaces. A series of articles on consuming Sharepoint object model can be found here and here.

In on of my previous posts, I wrote down the steps to access SharePoint list data using SharePoint object model and CAML queries.

Now, lets see how to consume the Sharepoint Web Services in order to retrieve the Sharepoint List Data.

Step By Step

  1. Create a new windows form project.
  2. Add Web Reference to Sharepoint Lists Web Service
    1. Right-click ‘Service Reference’ and select ‘Add Service Reference’.
    2. In the Add Service Reference dialog box, click Advanced button.
    3. In the ‘Service Reference settings’ dialog box, click Add Web Reference.
    4. In the Url dropdown box, enter the url of your sharepoint site’s web service. If you are developing in the same system as the system in which MOSS is installed, then you can find the web services by clicking the link ‘Web Services in this Solution’ available in the Add Web Reference dialog box.
      1. Note : The _vti_bin directory present under the sharepoint website directory lists down all the web services available.
    5. Scroll through the list of Web Services. Click in the ‘Lists’ web service. Check the url in the url column and ensure that this Lists web service corresponds to your sharepoint site.
    6. Lists Web Service
    7. In the Web Reference name text box, give a name to the Lists web reference. Lets name it ListsWS.
    8. Click Add Reference.
    9. AddWebReference
  3. Place a button in the form. Name it btnGetListItems and the Caption can be Get List Items. Double click the button and generate the event handler.
  4. The Lists web service contains an class called Lists. Lets create an object for this Lists class.
    1. ListsWS.Lists list = new ListsWS.Lists();
  5. The List object contains a method called GetListItems(). We need to invoke this method with appropriate parameters to get the items from the list
    1. The first parameter to this method is the name of the list.
    2. The remaining parameters are there to filter the list based on user defined criteria’s. Without any criteria, to fetch all the items from the list, the method should look like the following.
      1. list.GetListItems(“MyListName”, “”, null, null, “”, null,null);
      2. The signature of GetListItems in MSDN
  6. The return type of the GetListItems() is an Xml Node.
  7. The XmlNode’s inner xml looks like the following.
  8. We need to process the xml node in order to access the list values.
    1. Below, I have processed the xml to obtain the value of the column ‘Title’ that is present in the list and displayed it in a label.
  9. The entire code is given below

ListWS.Lists lists = new ListWS.Lists();
lists.UseDefaultCredentials = true;

    XmlNode nodes = lists.GetListItems(“MyList1”, “”, null, null, “”, null, null);foreach (XmlNode node in nodes)
    {
        if (node.Name == “rs:data”)
        {
            for (int i = 0; i < node.ChildNodes.Count; i++)
            {
                if (node.ChildNodes[i].Name == “z:row”)
                {
                   lblResults.Text =  node.ChildNodes[i].Attributes[“ows_Title”].Value;
                }
            }
        }
    }

Hope this helps.

Thanks.

Posted in MOSS 2007 | Tagged: , , , , , , , , , | 22 Comments »

Introduction to Site Templates

Posted by Ramprasad Navaneethakrishnan on May 9, 2009

Sharepoint 2007 comes with some out-of-the-box site templates that allows Administrators or Information Workers to readily create sites by choosing one of the available templates that suites their requirement.

The out-of-the-box Site Templates available with Sharepoint 2007 are broadly classified into 4 categories as mentioned below.

  1. Collaboration
  2. Meeting
  3. Enterprise
  4. Publishing

Collaboration Templates

  • Team Site:
    • This site is for team members to collaborate on any tasks or projects. To facilitate this type of collaboration, it includes the following webparts
      • Document library : To manage documents associated with the task / project
      • Announcement List : Create / Manage announcements with the project team
      • Discussion Board : A forum to discuss on tasks / issues assocaited with the project
      • Calendar Lists : Keeps track of the various schedules associated with team members / project
      • Task Lists : A list that keeps track of task items assigned against members of the project
      • Links : A single place to keep track of  links to sites that are needed for the project

 

teamsite

  • Blank Site:
    • As the name suggests, its just a blank site with no webparts populated by default. This is a good place for building a fully customized site.

 

blanksite

Document Workspace:

  • This template is suitable for a team documentation project or a team of technical writers where there is a need in creation and modification of common documentation.
  • It has the following webparts associated with it.
    • Document Library
    • Tasks List
    • Links

 

documentworkspace

  • Blog Site:
    • A site for a team or person to post ideas and observations which site visitors can comment to.

Meeting Templates

Basic Meeting:

  • A general purpose meeting template that helps to plan, organize and capture the results of the meeting using the following webparts associated with the site
    • Objectives list
    • Attendies
    • Agenda
    • Document Library

basicmeeting

  • Blank Meeting:
    • A blank meeting site that can be customized to suite the requirement
  • Decision Making Meeting:
    • This template is suitable when the purpose of the meeting is to reivew doucments, lists and other informations in order to make a decision. The webparts included are
      • Objectives list
      • Attendies
      • Agenda
      • Document Library
      • Tasks List
      • Decision List

decisionmeeting

 

  • Social Meeting:
    • This template comes handy when organizing a team picnic or party.  The web elements included are
      • Attendies list
      • Directions
      • Image Log
      • Thing to bring List
      • Photo Library
  • MultiPage Meeting:
    • This is similar to Decision Making template but it is designed to accomodate complex decision process. This site comes with two webpages by default and it can accomodate upto 10 individual pages. It includes
      • Objective Lists
      • Attendies Lists
      • Agenda

Enterprise

Enterprise templates are normally used as a top-level or high-level sites in an organizations site collection. It facilitated enterprise level activities in the areas of document management, records management and report management

  • Document Center:
    • A Site to centrally manage enterprise level documents. It has several document management features enabled by default like Major / Minor versionaing, Require check out etc. This templates includes the following webparts.
      • Document Library
      • Relevant documents
      • Upcoming tasks
      • Treeview webpart
  • Records Center:
    • This site template is used to centrally manage organizations data and data sources. The webparts included are
      • Records vault
      • Records routing list
      • Information management policy
      • Unassigned Records library

recordscenter

 

  • Site Directory:
    • A site template for listing, categorizing important sites in the organizations site collection. The webparts included are
      • Categorized Sites
      • Top Sites
      • Site Map
  • Report Center:
    • This site template as part of Sharepoint business intelligence solution communicates metrics, goals, statues and business intelligence informations by means of the foll0wing web elements
      • Dashboards
      • KPI indicators
      • Webpages

reportcenter

 

  • Search Center:
    • A site that enables users to seach for information. It includes webparts
      • SearchResults
      • Advanced Search
  • Search Center with tabs:
    • This is similar to search center except it comes with two tabs. One tab to search through information in the sites and the other tab ‘people’ that enables to search through peoples.

Publishing

  • News Site:
    • A site for publising news articles and links to news articles. The default webparts includes
    • Sample news page
    • Archive for storing older news

Hope this is useful.

A post on creating custom templates can be found here

Thanks.

Posted in MOSS 2007 | Tagged: , , , , , , , , , , , , , , , , , | 2 Comments »

Business Data Catalog in MOSS 2007

Posted by Ramprasad Navaneethakrishnan on September 26, 2008

Overview

As per Microsoft, Business Data Catalog (BDC) is a “new business integration feature available in Microsoft Office Sharepoint Server 2007. It is a shared service and it enables MOSS 2007 to surface business data from back-end server applications without any coding.”

Why BDC?

All the data entered into the Sharepoint system gets stored in the content database of that particular Sharepoint application. So by default, a Sharepoint site will get information from its content database. But it is quite natural for an organization to have information stored in multiple databases by numerous applications throughout the organization. For example, inventory software stores its data in a database that is different from a CRM software storing data in a database. But people will find is extremely useful if provided with a space where they can have every bit of information from each and every department in the organization ranging from the up-to-minute logistics information to the up-to-date sales analysis. The BDC feature of Microsoft Office Sharepoint Server 2007 provides the needed business integration for integrating the line of business (LOB) applications with the Sharepoint.

What is BDC?

Business Data Catalog provides built in support for displaying data from two data sources.

·         Databases

·         Web Services

Microsoft promises a “no coding” approach for integrating LOB applications with Sharepoint. Business Data Catalog provides access to the data sources through a metadata model that provides a consistent and simplified client object model. So it is the metadata authors who describe the API of the business applications in xml. After this, the administrators will associate this metadata with the Sharepoint application after which the LOB data is available in the Sharepoint system.

 


Development Environment

The walkthrough below will guide in developing a simple BDC application in MOSS 2007. The following states the database and MOSS settings used by this walkthrough.

MOSS Settings

·         Microsoft Office Sharepoint Server 2007 Enterprise Edition Installed.

o   Standard Edition of MOSS 2007 does not have BDC feature

·         Created a new web application named “KnowMax-1234” from Central Administration.

·         Use the default Shared Services Provider (SSP) associated with the created web application or create a new SSP for the web application KnowMax-1234.

Database details of LOB application

·         Database Server : TARGETMC-VM\SQLEXPRESS

·         Database Name : Test

·         Table Name : dbo.Product

·         Snapshot of the LOB Database :

 

Walkthrough:  Creating a product BDC from LOB database

Objective

The objective of this walkthrough is, “To access the LOB application’s data through BDC and display it in the Sharepoint site inside the Business Data Lists Webpart.” This Webpart will get the ‘ProductID’ as input from the user and gets the corresponding product details from the LOB database. The following is the snapshot of the output.

 

 

 

The “ProductID” is given as 1. And the product detail for this product id is obtained from the LOB database.

 

Authoring Metadata

Authoring the metadata forms the heart of the development process involved in creating the BDC application. Though there are many tools that promises to simplify this process, most of them are ambiguous or non freewares. Some of those tools are

·         Microsoft Business Data Catalog definition editor

o   Gets shipped with the Sharepoint 2007 SDK which is available free for download

·         Metaman

o   Metaman is supposedly good but it comes with a cost as Metaman is not a freeware

 

So avoiding all those ambiguities, let us start writing the BDC metadata in xml. To start of the process, open a notepad and follow the steps below

1.    Since the metadata is an xml file, it starts off with the following lines just like all xml documents

<?xml version=1.0 encoding=utf-8 standalone=yes?>

2.    The LobSystem tag defines the namespaces, the name of the LOB system, the type of the system (Database or Webservice) and the version of the system

<LobSystem xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:schemaLocation=http://schemas.microsoft.com/office/2006/03/BusinessDataCatalog BDCMetadata.xsd Type=Database Version=1.0.0.0 Name=ProductBDC1

xmlns=http://schemas.microsoft.com/office/2006/03/BusinessDataCatalog>

3.    Then create a new instance for this Lob system using the following lines

<LobSystemInstances>

<LobSystemInstance Name=ProductBDC1 >

4.    Define the database, connection and authentication properties of the Lob system using the properties tag.

<Properties>

        <Property Name=rdbconnection Data Source Type=System.String>TARGETMC-VM\SQLEXPRESS</Property>

        <Property Name=rdbconnection Initial Catalog Type=System.String>Test</Property>

        <Property Name=rdbconnection Integrated Security Type=System.String>SSPI</Property>

        <Property Name=DatabaseAccessProvider Type=Microsoft.Office.Server.ApplicationRegistry.SystemSpecific.Db.DbAccessProvider>SqlServer</Property>

        <Property Name=AuthenticationMode Type=Microsoft.Office.Server.ApplicationRegistry.SystemSpecific.Db.DbAuthenticationMode>PassThrough</Property>

        <Property Name=RdbConnection Pooling Type=System.String>false</Property>

      </Properties>

    </LobSystemInstance>

</LobSystemInstances>

5.    Now, create an entity and define its properties

  <Entities>

    <Entity EstimatedInstanceCount=100 Name=Product>

      <Properties>

<Property Name=Name Type=System.String>Name</Property>

      </Properties>

      <Identifiers>

   <Identifier Name=ProductID TypeName=System.String /></Identifiers>

These tags define the entity called Product and its two members, Name and ProductID.

6.    There should be a method that gets the details of the entity based on the input parameters.  The following tags define a method called “GetProducts” which has a query that gets the name and productid of the products entity based on the entered productid. Also the input parameter is defined using the parameter tag with Direction attribute as “In”. The output is the product entity having two members namely name and productid which is defined in the parameter tags with the Direction attribute as “Return”.

      <Methods>

        <Method Name=GetProducts>

          <Properties>

            <Property Name=RdbCommandText Type=System.String>

              SELECT ProductID, Name FROM Product WHERE ProductID = @ProductID

           </Property>

            <Property Name=RdbCommandType Type=System.Data.CommandType>Text</Property>

          </Properties>

          <FilterDescriptors>

            <FilterDescriptor Type=Comparison Name=ProductID>

              <Properties>

                <Property Name=Comparator Type=System.String>Equals</Property>

              </Properties>

            </FilterDescriptor>

          </FilterDescriptors>

          <Parameters>

            <Parameter Direction=In Name=@ProductID>

              <TypeDescriptor TypeName=System.String IdentifierName=ProductID AssociatedFilter=ProductID Name=ProductID>

                <DefaultValues>

                  <DefaultValue MethodInstanceName=ProductFinderInstance Type=System.String > 1 </DefaultValue>

                </DefaultValues>

              </TypeDescriptor>

            </Parameter>

            <Parameter Direction=Return Name=Products>

              <TypeDescriptor TypeName=System.Data.IDataReader, System.Data, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

IsCollection=true Name=ProductDataReader>

              <TypeDescriptors>

                <TypeDescriptor TypeName=System.Data.IDataRecord, System.Data, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

                                Name=ProductDataRecord>

                  <TypeDescriptors>

                    <TypeDescriptor TypeName=System.String IdentifierName=ProductID Name=ProductID>

                      <LocalizedDisplayNames>

                        <LocalizedDisplayName LCID=1033>ProductID</LocalizedDisplayName>

                      </LocalizedDisplayNames>

                    </TypeDescriptor>

                    <TypeDescriptor TypeName=System.String Name=Name>

                      <LocalizedDisplayNames>

                        <LocalizedDisplayName LCID=1033>Name</LocalizedDisplayName>

                      </LocalizedDisplayNames>

                      <Properties>

                        <Property Name=DisplayByDefault Type=System.Boolean>true</Property>

                      </Properties>

                    </TypeDescriptor>

                  </TypeDescriptors>

                </TypeDescriptor>

              </TypeDescriptors>

              </TypeDescriptor>

            </Parameter>

 </Parameters>

7.    Then create an instance for the “GetProducts” method like this.

<MethodInstances>

            <MethodInstance Name=ProductFinderInstance Type=Finder ReturnParameterName=Products />

          </MethodInstances>

 

The complete metadata definition xml is as follows. Copy it into a notepad and save as “ProductBDC.xml”.

<?xml version=1.0 encoding=utf-8 standalone=yes?>

<LobSystem xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:schemaLocation=http://schemas.microsoft.com/office/2006/03/BusinessDataCatalog BDCMetadata.xsd Type=Database Version=1.0.0.0 Name=ProductBDC1 xmlns=http://schemas.microsoft.com/office/2006/03/BusinessDataCatalog>

  <LobSystemInstances>

    <LobSystemInstance Name=ProductBDC1 >

      <Properties>

        <Property Name=rdbconnection Data Source Type=System.String>TARGETMC-VM\SQLEXPRESS</Property>

        <Property Name=rdbconnection Initial Catalog Type=System.String>Test</Property>

        <Property Name=rdbconnection Integrated Security Type=System.String>SSPI</Property>

        <Property Name=DatabaseAccessProvider Type=Microsoft.Office.Server.ApplicationRegistry.SystemSpecific.Db.DbAccessProvider>SqlServer</Property>

        <Property Name=AuthenticationMode Type=Microsoft.Office.Server.ApplicationRegistry.SystemSpecific.Db.DbAuthenticationMode>PassThrough</Property>

        <Property Name=RdbConnection Pooling Type=System.String>false</Property>

      </Properties>

    </LobSystemInstance>

  </LobSystemInstances>

  <Entities>

    <Entity EstimatedInstanceCount=100 Name=Product>

      <Properties>

        <Property Name=Name Type=System.String>Name</Property>

      </Properties>

      <Identifiers>

        <Identifier Name=ProductID TypeName=System.String />

      </Identifiers>

      <Methods>

        <Method Name=GetProducts>

          <Properties>

            <Property Name=RdbCommandText Type=System.String>

              SELECT ProductID, Name FROM Product WHERE ProductID = @ProductID

            </Property>

            <Property Name=RdbCommandType Type=System.Data.CommandType>Text</Property>

          </Properties>

          <FilterDescriptors>

            <FilterDescriptor Type=Comparison Name=ProductID>

              <Properties>

                <Property Name=Comparator Type=System.String>Equals</Property>

              </Properties>

            </FilterDescriptor>

          </FilterDescriptors>

          <Parameters>

            <Parameter Direction=In Name=@ProductID>

              <TypeDescriptor TypeName=System.String IdentifierName=ProductID AssociatedFilter=ProductID Name=ProductID>

                <DefaultValues>

                  <DefaultValue MethodInstanceName=ProductFinderInstance Type=System.String > 1 </DefaultValue>

                </DefaultValues>

              </TypeDescriptor>

            </Parameter>

            <Parameter Direction=Return Name=Products>

              <TypeDescriptor TypeName=System.Data.IDataReader, System.Data, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

                              IsCollection=true Name=ProductDataReader>

              <TypeDescriptors>

                <TypeDescriptor TypeName=System.Data.IDataRecord, System.Data, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

                                Name=ProductDataRecord>

                  <TypeDescriptors>

                    <TypeDescriptor TypeName=System.String IdentifierName=ProductID Name=ProductID>

                      <LocalizedDisplayNames>

                        <LocalizedDisplayName LCID=1033>ProductID</LocalizedDisplayName>

                      </LocalizedDisplayNames>

                    </TypeDescriptor>

                    <TypeDescriptor TypeName=System.String Name=Name>

                      <LocalizedDisplayNames>

                        <LocalizedDisplayName LCID=1033>Name</LocalizedDisplayName>

                      </LocalizedDisplayNames>

                      <Properties>

                        <Property Name=DisplayByDefault Type=System.Boolean>true</Property>

                      </Properties>

                    </TypeDescriptor>

                  </TypeDescriptors>

                </TypeDescriptor>

              </TypeDescriptors>

              </TypeDescriptor>

            </Parameter>

          </Parameters>

          <MethodInstances>

            <MethodInstance Name=ProductFinderInstance Type=Finder ReturnParameterName=Products />

          </MethodInstances>

        </Method>

      </Methods>

    </Entity>

  </Entities>

</LobSystem>

 

After authoring the metadata for the Lob system, we have to just associate this with a web application to make use the BDC.

 

1.    Go to the central administration and select your SSP.

2.    Under Business Data Catalog, click Import application definition

 

 

3.      Choose your metadata file and click “Import”

 

 

 

4.       A warning message will come. Click “Ok” as of now.

5.      You can see your imported application by clicking “View Application” under Business Data Catalog for your SSP

 

 

6.      Now, go to your Sharepoint site and click “Edit Page” under Site Actions

7.      Click “Add a Web Part”

8.      Select the “Business Data List” Web Part under Business Data and click Add

 

 

 

9.      In the newly added Business Data List Web Part click Edit and select Modify Shared Web Part

 

  10.  In the type textbox, click Browse

 

 

 

 

 

 

 

 

 

11.  In the Business Data Type Picker dialog box, select your BDC file and click Ok.

 

 

12.  Click Ok in the business data list properties window (screen shot in step 10.)

13.  Now the Webpart will look like the following.

 

 

 

 

14.  Enter 1 in the productid textbox and click “Retrieve Data”.

15.  The product name associated with the product id in the LOB database gets retrieved like the following.

 

 

Posted in MOSS 2007 | Tagged: , , , , , , , , , | 5 Comments »