locked
Lists.asmx webservice ows metainfo RRS feed

  • Question

  • note:sharepoint 2007 webservice lists.asmx to read a list from a remote site

    How to remove ows in the header

    how to Remove unnecessary meta data in lists.asmx

     

    Thanks


    Like Cricket
    Monday, September 19, 2011 12:17 PM

Answers

  • You can define the output view field when you call the web Service "lists.GetListItems ".

    <ViewFields>
       <FieldRef Name="ID" />
       <FieldRef Name="Title" />
    </ViewFields>

    This links will help you

    Lists.GetListItems Method

    http://msdn.microsoft.com/en-us/library/lists.lists.getlistitems%28v=office.12%29.aspx


    André Lage Microsoft SharePoint, CRM and Sybase Consultant
    Blog:http://aaclage.blogspot.com
    Codeplex:http://spupload.codeplex.com/http://simplecamlsearch.codeplex.com/
    • Marked as answer by h_user2016 Wednesday, October 12, 2011 7:18 AM
    Monday, September 19, 2011 1:51 PM
    • Marked as answer by h_user2016 Wednesday, October 12, 2011 7:19 AM
    Thursday, September 22, 2011 8:44 PM
  • Hi,

    Unfortunately I think you will have to simply do a manual string replace. You can pull the data from the lists.asmx service into a DataSet object which will automatically map the list items to rows and the list fields to columns in the DataSet. Then when you loop through the rows and retrieve the fields simply do a String.Replace on the column name and replace the "ows_" with "". That will remove the ows_ prefix.

    I hope this helps.

    • Marked as answer by h_user2016 Wednesday, October 12, 2011 7:19 AM
    Friday, September 23, 2011 8:51 PM
  • /*Declare and initialize a variable for the Lists Web service.*/
    Web_Reference.Lists listService = new Web_Reference.Lists();
    /*Authenticate the current user by passing their default 
    credentials to the Web service from the system credential cache.*/
    listService.Credentials = 
        System.Net.CredentialCache.DefaultCredentials;
    /*Set the Url property of the service for the path to a subsite.*/
    listService.Url = 
        "http://Server_Name/Subsite_Name/_vti_bin/Lists.asmx";
    /* Instantiate an XmlDocument object */
    System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
    /* Assign values to the string parameters of the GetListItems method, 
    using GUIDs for the listName and viewName variables. For listName, 
    using the list display name will also work, but using the list GUID 
    is recommended. For viewName, only the view GUID can be used. 
    Using an empty string for viewName causes the default view to be used.*/
    string listName = "{17991794-81BB-494F-9910-CFBF1093A7CF}";
    string viewName = "{7137FFF8-48FF-4C69-8C76-0E3BBD1EA7F9}";
    string rowLimit = "150";
    /*Use the CreateElement method of the document object to create 
    elements for the parameters that use XML.*/
    System.Xml.XmlElement query = xmlDoc.CreateElement("Query");
    System.Xml.XmlElement viewFields = 
        xmlDoc.CreateElement("ViewFields");
    System.Xml.XmlElement queryOptions = 
        xmlDoc.CreateElement("QueryOptions");
    /*To specify values for the parameter elements (optional), assign 
    CAML fragments to the InnerXml property of each element.*/
    query.InnerXml = "<Where><Gt><FieldRef Name=\"ID\" />" +
        "<Value Type=\"Counter\">3</Value></Gt></Where>";
    viewFields.InnerXml = "<FieldRef Name=\"Title\" />";
    queryOptions.InnerXml = "";
    /* Declare an XmlNode object and initialize it with the XML response 
    from the GetListItems method. The last parameter specifies the GUID 
    of the Web site containing the list. Setting it to null causes the 
    Web site specified by the Url property to be used.*/
    System.Xml.XmlNode nodeListItems = 
        listService.GetListItems
        (listName, viewName,query,viewFields,rowLimit,queryOptions,null);
    /*Loop through each node in the XML response and display each item.*/
    foreach (System.Xml.XmlNode listItem in nodeListItems)
    {
        label1.Text += listItem.OuterXml;
    }
    Declare the dataset above the foreach loop then add the rows to dataset.
    in the Query mention the view fields which you want.
    • Marked as answer by Wayne Fan Sunday, October 9, 2011 12:43 PM
    Saturday, September 24, 2011 6:47 AM

All replies

  • You can define the output view field when you call the web Service "lists.GetListItems ".

    <ViewFields>
       <FieldRef Name="ID" />
       <FieldRef Name="Title" />
    </ViewFields>

    This links will help you

    Lists.GetListItems Method

    http://msdn.microsoft.com/en-us/library/lists.lists.getlistitems%28v=office.12%29.aspx


    André Lage Microsoft SharePoint, CRM and Sybase Consultant
    Blog:http://aaclage.blogspot.com
    Codeplex:http://spupload.codeplex.com/http://simplecamlsearch.codeplex.com/
    • Marked as answer by h_user2016 Wednesday, October 12, 2011 7:18 AM
    Monday, September 19, 2011 1:51 PM
  • Still I am unable to get.
    Like Cricket
    Tuesday, September 20, 2011 6:14 AM
  • Are you calling the webservice with JavaScript or C#/VB.NET?


    Gabriel Renom - Business Systems Analyst - Pannone LLP Blog: http://www.gabrielrenom.net
    Tuesday, September 20, 2011 8:49 AM
  • I need to populate only necessary columns in my dataset .
    • Edited by h_user2016 Tuesday, September 20, 2011 11:01 AM
    Tuesday, September 20, 2011 9:32 AM
    • Marked as answer by h_user2016 Wednesday, October 12, 2011 7:19 AM
    Thursday, September 22, 2011 8:44 PM
  • Hi,

    Unfortunately I think you will have to simply do a manual string replace. You can pull the data from the lists.asmx service into a DataSet object which will automatically map the list items to rows and the list fields to columns in the DataSet. Then when you loop through the rows and retrieve the fields simply do a String.Replace on the column name and replace the "ows_" with "". That will remove the ows_ prefix.

    I hope this helps.

    • Marked as answer by h_user2016 Wednesday, October 12, 2011 7:19 AM
    Friday, September 23, 2011 8:51 PM
  • /*Declare and initialize a variable for the Lists Web service.*/
    Web_Reference.Lists listService = new Web_Reference.Lists();
    /*Authenticate the current user by passing their default 
    credentials to the Web service from the system credential cache.*/
    listService.Credentials = 
        System.Net.CredentialCache.DefaultCredentials;
    /*Set the Url property of the service for the path to a subsite.*/
    listService.Url = 
        "http://Server_Name/Subsite_Name/_vti_bin/Lists.asmx";
    /* Instantiate an XmlDocument object */
    System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
    /* Assign values to the string parameters of the GetListItems method, 
    using GUIDs for the listName and viewName variables. For listName, 
    using the list display name will also work, but using the list GUID 
    is recommended. For viewName, only the view GUID can be used. 
    Using an empty string for viewName causes the default view to be used.*/
    string listName = "{17991794-81BB-494F-9910-CFBF1093A7CF}";
    string viewName = "{7137FFF8-48FF-4C69-8C76-0E3BBD1EA7F9}";
    string rowLimit = "150";
    /*Use the CreateElement method of the document object to create 
    elements for the parameters that use XML.*/
    System.Xml.XmlElement query = xmlDoc.CreateElement("Query");
    System.Xml.XmlElement viewFields = 
        xmlDoc.CreateElement("ViewFields");
    System.Xml.XmlElement queryOptions = 
        xmlDoc.CreateElement("QueryOptions");
    /*To specify values for the parameter elements (optional), assign 
    CAML fragments to the InnerXml property of each element.*/
    query.InnerXml = "<Where><Gt><FieldRef Name=\"ID\" />" +
        "<Value Type=\"Counter\">3</Value></Gt></Where>";
    viewFields.InnerXml = "<FieldRef Name=\"Title\" />";
    queryOptions.InnerXml = "";
    /* Declare an XmlNode object and initialize it with the XML response 
    from the GetListItems method. The last parameter specifies the GUID 
    of the Web site containing the list. Setting it to null causes the 
    Web site specified by the Url property to be used.*/
    System.Xml.XmlNode nodeListItems = 
        listService.GetListItems
        (listName, viewName,query,viewFields,rowLimit,queryOptions,null);
    /*Loop through each node in the XML response and display each item.*/
    foreach (System.Xml.XmlNode listItem in nodeListItems)
    {
        label1.Text += listItem.OuterXml;
    }
    Declare the dataset above the foreach loop then add the rows to dataset.
    in the Query mention the view fields which you want.
    • Marked as answer by Wayne Fan Sunday, October 9, 2011 12:43 PM
    Saturday, September 24, 2011 6:47 AM