使用数据源过滤器 - Sharepoint SOAP查询外部内容类型(外部列表)

时间:2013-05-23 15:21:33

标签: c# sharepoint sharepoint-2010 sharepoint-designer

我将sharepoint连接到sql server db。我根据外部内容类型制作了一个列表。由于数据量,我必须在添加外部内容类型操作 - 列表中添加过滤器参数。我添加了带有默认值的通配符和限制过滤器。我在外部内容类型上创建了列表。 我运行默认列表网站。我没有看到任何数据。所以我编辑网页和

        <Method Name="ExternalList">
            <Filter Name="Filter" Value="A*"/>
            <Filter Name="Limit" Value="50"/>
        </Method>

以这种方式运作。

我在C#wpf应用程序中写道

            server.Lists client = new server.Lists();
            client.Url = string.Format("{0}/_vti_bin/Lists.asmx", FixUrl("http://server:port/sites/SiteCollecion/"));
            client.Credentials = System.Net.CredentialCache.DefaultCredentials;
         try
            {
                string xmlQueryContent = @"<Query xmlns=""http://schemas.microsoft.com/sharepoint/soap/""></Query>";
                XmlDocument docQuery = new XmlDocument();
                docQuery.LoadXml(xmlQueryContent.ToString());
                XmlNode QueryNode = docQuery.DocumentElement;

                string xmlQueryOptionsContent = @"<QueryOptions></QueryOptions>";
                XmlDocument docQueryOptions = new XmlDocument();
                docQueryOptions.LoadXml(xmlQueryOptionsContent.ToString());
                XmlNode QueryOptionsNode = docQueryOptions.DocumentElement;

                XmlNode clientsNode = client.GetListItems("ExternalList", null, QueryNode, null, null, null, null);
                DataSet clientsListsDataSet = new DataSet();
                XmlReader clientsReader = new XmlNodeReader(clientsNode);
                XmlReadMode oko = clientsListsDataSet.ReadXml(clientsReader);

                Console.WriteLine(clientsNode.InnerText);
                Console.WriteLine(clientsNode.InnerXml);
             }

我获得了0行结果。所以过滤器没有填充。 可以在C#应用程序中设置它们吗?

连接正常,因为当我连接到非外部列表时,我得到了结果。

1 个答案:

答案 0 :(得分:1)

您可以尝试使用REST / oData Web服务来访问列表项,过滤器等功能是REST / oData协议的一部分。

您可以直接从网址过滤项目和分页,例如:

/Products?$filter=ID lt 4

代码项目上的OData示例

http://www.codeproject.com/Articles/393623/OData-Services/

要在SharePoint 2010中访问Rest / oData服务,请使用_vti_bin

/MySite/MySubSite/_vti_bin/listdata.svc/ExternalList

以下是关于odata与windows应用程序的一些文章和博客:

http://www.c-sharpcorner.com/UploadFile/54db21/insert-data-from-sharepoint-list-using-odata-service/

http://www.orbitone.com/en/blog/archive/2010/06/09/odata-and-wcf-data-services.aspx

如果REST / odata没有自动转动,您可能需要安装一个小补丁。