Web服务安全性异常

时间:2014-07-17 09:12:53

标签: c# web-services sharepoint

对于工作我需要创建一个从sharepoint列表获取信息的web服务,我在互联网上找到了一个应该这样做的功能,但是我得到了一个安全例外

System.Security.SecurityException:System.Net.WebPermission类型的权限请求,System,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089失败。

有谁知道如何解决这个问题?信任程度很高,所以不是这样。我现在在互联网上搜索了几天,可以找到一件事。

code:
        [WebMethod]
            public string GetListItems()
        {
            String sResult = "";
            WS_Lists.Lists listService = new WS_Lists.Lists();
            listService.Credentials = new NetworkCredential("Username", "Password", "Domain");

            listService.Url = "http://ws-0622/_vti_bin/Lists.asmx";

            System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();

            string listName = "{B476DFD7-37F1-4FE8-BCCB-41B3DA87FF8C}";
            string viewName = "{7137FFF8-48FF-4C69-8C76-0E3BBD1EA7F9}";
            string rowLimit = "150";

            System.Xml.XmlElement query = xmlDoc.CreateElement("Query");
            System.Xml.XmlElement viewFields =
                xmlDoc.CreateElement("ViewFields");
            System.Xml.XmlElement queryOptions =
                xmlDoc.CreateElement("QueryOptions");

            query.InnerXml = "<Where><Gt><FieldRef Name=\"ID\" />" +
                "<Value Type=\"Counter\">3</Value></Gt></Where>";
            viewFields.InnerXml = "<FieldRef Name=\"Title\" />";
            queryOptions.InnerXml = "";

            System.Xml.XmlNode nodeListItems =
                listService.GetListItems
                (listName, viewName, query, viewFields, rowLimit, queryOptions, null);

            foreach (System.Xml.XmlNode listItem in nodeListItems)
            {
                sResult += listItem.OuterXml;
            }

            return sResult;
        }

提前致谢

0 个答案:

没有答案