为什么 Sharepoint 2010 Web 参考可以工作,但服务参考却不能

发布于 2024-08-24 14:49:44 字数 3097 浏览 3 评论 0原文

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");

    }

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

更新:

我尝试了罗布的建议并收到此错误:

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

    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').'.

Sharepoint is setup to use NTLM authentication.

When I reference http://myserver/Sites/Ops/_vti_bin/Lists.asmx?WSDL as a Web Reference, I can call the methods and get valid responses.

When I reference the same url as a Service Reference, the server throws an exception when calling methods.

My account is admin on the Sharepoint Farm.

This is the app.config for the service reference (mostly auto generated):

<?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>

Saddly, the only information the exception provides is this:

"Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown."

No other details.

The code that I'm using is:

 public ListClass()
    {

        _Client = new SharepointLists.ListsSoapClient();

    }

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

    }

Any thoughts? I would like to use the Service Reference rather than the Web Reference.

UPDATE:

I tried Rob's suggestion and got this error:

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

was not recognized as a known document type.
The error message from each known type may help you fix the problem:
- Report from 'http://myserver/Sites/Ops/_vti_bin/Lists.asmx' is 'The document
format is not recognized (the content type is 'text/html;
charset=utf-8').'.
- Report from 'DISCO Document' is 'There was an error downloading
'http://myserver/_vti_bin/Lists.asmx?disco'.'.
- The request failed with HTTP status 404: Not Found.
- Report from 'WSDL Document' is 'The document format is not recognized
(the con
tent type is 'text/html; charset=utf-8').'.
- Report from 'XML Schema' is 'The document format is not recognized (the
conten
t type is 'text/html; charset=utf-8').'.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

别忘他 2024-08-31 14:49:44

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

这篇博文应该可以帮助您 http://nayyeri.net/integrating-wcf-具有 asmx 服务的客户端

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文