Web services 从外部windows应用程序编辑SharePoint2010列表。
实际上,我正在尝试从windows应用程序向共享点列表中添加项目。当我添加了web参考并能够获得Lists.asmx中列出的所有产品时,一切都很顺利。 当我执行我的程序并尝试调用listServiceObj.GetListAndview(“客户”和“”)时; 它给了我一个错误“请求失败,HTTP状态为401:Unauthorized”。请注意,此时我的凭据和服务引用的url为Web services 从外部windows应用程序编辑SharePoint2010列表。,web-services,sharepoint-2010,custom-lists,Web Services,Sharepoint 2010,Custom Lists,实际上,我正在尝试从windows应用程序向共享点列表中添加项目。当我添加了web参考并能够获得Lists.asmx中列出的所有产品时,一切都很顺利。 当我执行我的程序并尝试调用listServiceObj.GetListAndview(“客户”和“”)时; 它给了我一个错误“请求失败,HTTP状态为401:Unauthorized”。请注意,此时我的凭据和服务引用的url为 SpListService.Lists spListService = new SpListServic
SpListService.Lists spListService = new SpListService.Lists();
spListService.Credentials = System.Net.CredentialCache.DefaultCredentials;
spListService.Url = "http://localhost/_vti_bin/Lists.asmx";
XmlNode customerListView = spListService.GetListAndView("Customers", "");
然后我把上面的代码改成了
SpListService.Lists spListService = new SpListService.Lists();
spListService.Credentials = System.Net.CredentialCache.DefaultCredentials;
spListService.Url = "http://<PC-Name>/sites/Home/_vti_bin/Lists.asmx";
XmlNode customerListView = spListService.GetListAndView("Customers", "");
SpListService.Lists SpListService=new SpListService.Lists();
spListService.Credentials=System.Net.CredentialCache.DefaultCredentials;
spListService.Url=”http:///sites/Home/_vti_bin/Lists.asmx";
XmlNode customerListView=spListService.GetListAndView(“客户”,即“”);
然后我收到了以下错误
“引发了类型为“Microsoft.SharePoint.SoapServer.SoapServerException”的异常。”
我已使登录用户进入完全控制组。也是管理员组的成员。。但同样的结果。。。。
另外请注意,当尝试访问时“http://localhost/或“http://”它给我SP2010的拒绝访问页面。。。。相反,我必须写“http:///sites/Home/SitePages/Home.aspx“打开我的团队网站集
我真的很坚持。。。。我真的很高兴能为我的这个问题找到一些解决办法。。。。。。提前谢谢
MJay我在实现第一个SharePoint列表Web服务客户端时遇到了类似的问题。原因是自动生成的客户机类实际上在默认情况下作为Mozilla web浏览器引入了自己!SharePoint服务器不允许对浏览器进行基本身份验证,因此客户端实际上被重定向到防火墙登录页 我建议您从List类继承另一个类,并执行以下操作:
public class CustomizedLists : Lists
{
public CustomizedLists() : base()
{
this.UserAgent = "Some SharePoint client";
this.PreAuthenticate = true;
System.Net.ICredentials creds = new System.Net.NetworkCredential("user", "pwd");
this.Credentials = creds.GetCredential(uri, "Basic");
}
}
将Url更改为:“spListService.Url=”“发生以下错误。可能的SOAP版本不匹配:信封命名空间意外。预期。由于这主要是一个身份验证问题,您应该使用一个问题主题来引用此类。在何处编写此代码。。。实际上,我正在尝试在widows应用程序中使用此Lists.asmx服务。。。。我是Share Point的新手,你能指导我解决这个问题吗?这个例子实际上与SharePoint无关,因为它只是使用C#进行的基本面向对象编程。只需创建一个名为“CustomizedList”的新类,该类遵循下面的示例。不要忘记名称空间!然后,在创建Web服务客户端实例时,使用CustomizedLists类而不是List。