【问题标题】:Cannot get Sharepoint 2010s Lists.asmx service to work无法让 Sharepoint 2010s Lists.asmx 服务工作
【发布时间】:2015-07-30 13:09:30
【问题描述】:

我正在尝试访问 Sharepoint 2010 的 Lists.asmx Web 服务。我在 C# 中创建了新的控制台项目,添加了对 Web 服务 (http://[SITE]/_Vti_Bin/Lists.asmx) 的引用,它发现 Lists Web 服务没问题。但是,当我尝试做

ListsService.Lists objLists = new ...

它说列表不存在!在对象查看器中,我在 ListsService 命名空间中看到了各种各样的东西:

AddAttachmentRequest
AddAttachmentRequestBody
....

但我没有看到列表。但是,我在网上找到的每个示例都说,在我添加引用后,我应该在命名空间中有 Lists...

我做错了什么?

编辑:app.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup> 
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="ListsSoap" />
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://SITE/_Vti_Bin/Lists.asmx"
            binding="basicHttpBinding" bindingConfiguration="ListsSoap"
            contract="ListsService.ListsSoap" name="ListsSoap" />
    </client>
</system.serviceModel>
</configuration>

【问题讨论】:

    标签: c# web-services sharepoint sharepoint-2010


    【解决方案1】:
    1. 确保您正在执行 ListsService.Lists objLists = new ListsService.Lists()(不是“new Lists()”)

    2. 确保在 Settings.settings 文件和 web.config/app.config 文件中正确设置了 Web 服务引用。尝试删除 Web 服务引用并重新添加它

    【讨论】:

    • ListsService 不包含列表,这就是问题所在。我的应用配置如下(更新的OP)
    • 试试 ListsService.ListsSoap.Lists()
    • ListsSoap 是一个接口,有很多 AddAttachment、AddList 之类的东西,但它没有“Lists()”方法
    • 我这里是从记忆中去的,所以我不确定,但你可以试试: ListServices.ListsSoap L = new ListServices.ListsSoap() 然后查看 L 上可用的内容目的。也许 L.Lists()
    【解决方案2】:

    问题是我创建了“服务”引用,而不是“Web 服务”引用。您必须单击“高级”,然后单击“添加 Web 服务引用”才能添加 Web 服务引用,否则它会创建一个工作方式不同的 WCF 服务引用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-11-28
      • 2018-09-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多