0

I want to read out websites (titel) in a sitecollection in Sharepoint 2010 (by svc). I get the listinfo by "listdata.svc" (http://www.xxx/websites/Web1Site/_vti_bin/Listdata.svc). How I get the websites? I am looking for a good source about using wcf by sharepoint. thanks.

PS.: this is my current code:

            c_1steWebsitesammlungDataContext dataContext = new c_1steWebsitesammlungDataContext
                (new Uri("http://www.xxx/websites/Web1Site/_vti_bin/listdata.svc/"));

            dataContext.Credentials = CredentialCache.DefaultNetworkCredentials;

            var result = from items in dataContext.BW_ScoreList01 select new 
             { Name = items.NrFrage, items.Fragetext, items.Antwort1Wahl0 };

            DataTable dt = new DataTable("myTable");
            DataColumn column;
            DataRow row;

            column = new DataColumn();
            //column.DataType = System.Type.GetType("String");
            column.ColumnName = "NrFrage";
            dt.Columns.Add(column);

            column = new DataColumn();
            //column.DataType = System.Type.GetType("String");
            column.ColumnName = "Fragetext";
            dt.Columns.Add(column);

            column = new DataColumn();
            //column.DataType = System.Type.GetType("String");
            column.ColumnName = "Antwort1Wahl0";
            dt.Columns.Add(column);

            string a;


            foreach (var item in result)
            {
                row = dt.NewRow();
                a = item.Name.ToString();
                row["NrFrage"] = a;
                a = item.Fragetext.ToString();
                row["Fragetext"] = a;
                a = item.Antwort1Wahl0.ToString();
                row["Antwort1Wahl0"] = a;
                dt.Rows.Add(row);
            }

            dataGridView.DataSource = dt;
Rotaney
  • 247
  • 1
  • 3
  • 17

2 Answers2

0

Is the SPSite object an option for you? You can add a reference to Microsoft.Sharepoint, and construct the object using the site url.

pekoponian
  • 41
  • 3
  • okay, I think you can look at the Webs.asmx web service from WSS 3.0, which seems to be the same in SP2010... http://msdn.microsoft.com/en-us/library/websvcwebs.webs.getwebcollection(v=office.14).aspx – pekoponian Feb 13 '13 at 15:34
0

I think you are using the wrong service - if the goal is to get a list of Sites (webs) in a particular collection, the websvcsites service is the one you should use.

http://msdn.microsoft.com/en-us/library/websvcsites(v=office.14).aspx

Note one thing - when you are working with WCF, you have to make sure you are under the context of the site otherwise permissions can be an issue. This is true even in the object model - getting all SPWebs under a site can fail if the account in use doesn't have permssions to one of them.

David Sterling
  • 385
  • 1
  • 5