【问题标题】:Why does Sharepoint 2010 Web Reference work, but Service Reference does not为什么 Sharepoint 2010 Web Reference 可以工作,但 Service Reference 不能
【发布时间】:2010-03-08 03:52:13
【问题描述】:

Sharepoint 设置为使用 NTLM 身份验证。

当我引用 http://myserver/Sites/Ops/_vti_bin/Lists.asmx?WSDL 作为 Web 引用时,我可以调用方法并获得有效响应。

当我引用与服务引用相同的 url 时,服务器在调用方法时会抛出异常。

我的帐户是 Sharepoint Farm 的管理员。

这是服务参考的 app.config(主要是自动生成的):

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
    </configSections>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="ListsSoap" closeTimeout="00:01:00" openTimeout="00:01:00"
                    receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
                    bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                    useDefaultWebProxy="true">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                  <security mode="TransportCredentialOnly">
                    <transport clientCredentialType="Ntlm" />  
                  </security>
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://myserver/Sites/Ops/_vti_bin/Lists.asmx"
                binding="basicHttpBinding" bindingConfiguration="ListsSoap"
                contract="SharepointLists.ListsSoap" name="ListsSoap" />
        </client>
    </system.serviceModel>
</configuration>

可悲的是,异常提供的唯一信息是:

“引发了 'Microsoft.SharePoint.SoapServer.SoapServerException' 类型的异常。”

没有其他细节。

我使用的代码是:

 public ListClass()
    {

        _Client = new SharepointLists.ListsSoapClient();

    }

    public System.Xml.Linq.XElement GetTaskList()
    {
        return _Client.GetList("Tasks");

    }

有什么想法吗?我想使用服务参考而不是网络参考。

更新:

我尝试了 Rob 的建议并得到了这个错误:

HTTP GET Error
    URI: http://myserver/Sites/Ops/_vti_bin/Lists.asmx

    The document at the url http://myserver/Sites/Ops/_vti_bin/Lists.asmx

未被识别为已知的文档类型。 来自每种已知类型的错误消息可能会帮助您解决问题: - 来自“http://myserver/Sites/Ops/_vti_bin/Lists.asmx”的报告是“文档 格式不被识别(内容类型是'text/html; 字符集=utf-8')。'。 - 来自“DISCO 文档”的报告是“下载时出错 'http://myserver/_vti_bin/Lists.asmx?disco'.'。 - 请求失败,HTTP 状态为 404:未找到。 - 来自“WSDL 文档”的报告是“无法识别文档格式 (缺点 帐篷类型是'text/html;字符集=utf-8')。'。 - 来自“XML Schema”的报告是“无法识别文档格式( 内容 t 类型是 'text/html; charset=utf-8').'.

【问题讨论】:

    标签: .net sharepoint asmx sharepoint-2010 service-reference


    【解决方案1】:

    “添加服务引用”对话框不会为 ASMX 服务生成正确的配置。您需要改用 svcutil。

    这篇博文应该能帮到你http://nayyeri.net/integrating-wcf-clients-with-asmx-services

    【讨论】:

    • @Rob 我很欣赏 Rob 的建议,但不幸的是这不起作用。我用错误更新了我的帖子。
    • (迟来的错字修复和否决)@Rob:-1:该博文来自 2007 年。“添加服务参考”与 ASMX Web 服务或任何其他基本 SOAP Web 服务配合得很好。它只是使用 basicHttpBinding。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-04-07
    • 1970-01-01
    • 2018-06-13
    • 2020-05-31
    • 1970-01-01
    • 2021-09-03
    • 1970-01-01
    相关资源
    最近更新 更多