harepoint 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.
- Sharepoint Object Model
- 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
- Create a new windows form project.
- Add Web Reference to Sharepoint Lists Web Service
- Right-click ‘Service Reference’ and select ‘Add Service Reference’.
- In the Add Service Reference dialog box, click Advanced button.
- In the ‘Service Reference settings’ dialog box, click Add Web Reference.
- 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.
- Note : The _vti_bin directory present under the sharepoint website directory lists down all the web services available.
- 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.
- In the Web Reference name text box, give a name to the Lists web reference. Lets name it ListsWS.
- Click Add Reference.
- 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.
- The Lists web service contains an class called Lists. Lets create an object for this Lists class.
- ListsWS.Lists list = new ListsWS.Lists();
- The List object contains a method called GetListItems(). We need to invoke this method with appropriate parameters to get the items from the list
- The first parameter to this method is the name of the list.
- 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.
- list.GetListItems(“MyListName”, “”, null, null, “”, null,null);
- The signature of GetListItems in MSDN
- The return type of the GetListItems() is an Xml Node.
- The XmlNode’s inner xml looks like the following.
- We need to process the xml node in order to access the list values.
- 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.
- 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;
- }
}
}
}
Oh my goodness! Impressive article dude! Thank you, However I am going through troubles
ReplyDeletewith your RSS. I don't understand why I can't subscribe to it.
Is there anybody else getting the same RSS issues?
Anyone that knows the solution will you kindly respond?
Thanks!!
my website ... best registry cleaner
My site :: registry cleaner
Heya i am for the first time here. I found this board and I find It truly useful & it helped me out a lot.
ReplyDeleteI hope to give something back and help others like you aided me.
Feel free to visit my web page: diet plan for women
This post is genuinely a pleasant one it helps new
ReplyDeletethe web viewers, who are wishing in favor of blogging.
My web-site www.grabthebucket.com
Right here is the perfect blog for everyone who would like to understand this topic.
ReplyDeleteYou know a whole lot its almost hard to
argue with you (not that I personally would want to…HaHa).
You certainly put a fresh spin on a subject which has been discussed for a long time.
Excellent stuff, just great!
Feel free to surf to my web blog :: forex system review
I know this if off topic but I'm looking into starting my own blog and was curious what all is required to get setup? I'm assuming having a blog like yours would cost a pretty penny?
ReplyDeleteI'm not very internet savvy so I'm not 100% certain. Any
suggestions or advice would be greatly appreciated.
Thanks
Feel free to visit my web page :: selling options
Asking questions are really good thing if you are not understanding anything completely, however this
ReplyDeletearticle offers fastidious understanding yet.
Also visit my site: laser hair removal *http://www.hiarabs.com/blog/163129/secrets-driving-long-hairstyles*
Great post. I was checking constantly this blog and I'm impressed! Very useful info specially the last part :) I care for such info a lot. I was looking for this certain info for a very long time. Thank you and good luck.
ReplyDeletemy site - longer hair
Hi there, There's no doubt that your site may be having browser compatibility problems. Whenever I look at your blog in Safari, it looks fine however, when opening in IE, it has some overlapping issues. I just wanted to give you a quick heads up! Besides that, wonderful website!
ReplyDeleteMy web-site hair straightener
hey
ReplyDeleteone of best link on services
thanks for share