1
votes

I'm very new to Sharepoint, I have an aspx page on a Sharepoint site that shows a list of fields, including First Name, Last Name, etc. I'm have a console app, in Visual Studio, I'm using for testing communication and data transfer capability between between one web service and another; namely Sharepoint and another web service. My goal is to populate the various fields in the list on my Sharepoint site with data from the other web service. I'm using a web reference to the Lists Web Service on my Sharepoint server to try and gain access to fields in this particular list on the Sharepoint site. I have the following code:

''Name of my web reference to Lists Web Service is "sharepoint"
        Dim sharepointList As New sharepoint.Lists()
        sharepointList.Credentials = System.Net.CredentialCache.DefaultCredentials

        Dim testLists As XmlNode = sharepointList.GetListCollection
        Dim xmlText As String = testLists.InnerXml
        Dim xmlElement As XmlAttributeCollection = testLists.Attributes

I've been trying to find where this particular list is. I'll admit I'm not sure where I'm supposed to be looking, as the above code demonstrates. I've been using the debugger to analyze each of the above variables to try and find where in the XML this particular list is defined. Any help or insight is appreciated.

Here is a snapshot of the Sharepoint page containing the list I'm trying to search for:

alt text

UPDATE:

I decided to use the GetList() function and passed the name "New Hires" to it. It ended up grabbing the list above. Now I'm just trying to see if I can get access to just the fields pictured above, analyzing the xml it seems like those are just display names, the actual fieldID is some alpha numeric string, i.e. Display Name = "Business Phone" has the Field ID = "{fd630629-c165-4513-b43c-fdb16b86a14d}". I'm wondering if there's a way to search fields by Display Name.

2
The GetList method returns information about the list itself (schema), but not the actual data in it. What you want is the GetListItems method, which accepts a query (written using Collaborative Application Markup Language, or CAML) that works a bit like SQL. You can also tell the method to only return you a certain subset of fields, which you specify by Column Name or GUID (neither of these is the same as Display Name).CBono

2 Answers

0
votes

It's a two-pronged approach.

First, you need to access the SharePoint service from the context of the particular site that your list resides in. For example, if the URL to your list was:

http://sharepoint/foo/bar/baz/Lists/MyList

You would access the List Web Service from: http://sharepoint/foo/bar/baz/_vti_bin/lists.asmx

Now you're in the correct site collection. The remaining step would be to specify the list via name or GUID when you call one of the List methods. For example, if you were calling the UpdateListItems method (and it sounds like you will be), you'd use:

sharepoint.UpdateListItems( "{B1DC8A9C-2316-41AD-875B-01C9D4BD19F8}", myUpdateXml );

or

sharepoint.UpdateListItems( "MyList", myUpdateXml );

Obviously, list name will correspond to the actual list name you see in the list's URL. The GUID can be found by viewing the list in SharePoint, then navigating to Settings > List Settings and grabbing it from the URL (look for the List querystring parameter). It will be encoded, but you can use a utility like URL Decoder/Encoder to decode it to a proper GUID. Be sure to remember to use the {} brackets when sending in the GUID as a parameter.