1

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 ”的报告是“无法识别文档格式(内容类型是“文本/ html; charset=utf-8').'. - 来自“DISCO 文档”的报告是“下载“ http://myserver/_vti_bin/Lists.asmx?disco ”时出错。”。- 请求失败,HTTP 状态为 404:未找到。- 来自“WSDL 文档”的报告是“无法识别文档格式(内容类型为 'text/html; charset=utf-8')。”。- 来自“XML Schema”的报告是“无法识别文档格式(内容类型为” 文本/html;字符集=utf-8')。'。

4

1 回答 1

1

The Add Service Reference dialog does not generate the proper configuration for an ASMX service. You need to use svcutil instead.

This blog post should help you http://nayyeri.net/integrating-wcf-clients-with-asmx-services

于 2010-03-15T13:34:25.740 回答