为什么Sharepoint 2010 Web引用可以正常工作,但Service Reference不是
Sharepoint设置为使用NTLM身份验证。为什么Sharepoint 2010 Web引用可以正常工作,但Service Reference不是
当我参考http://myserver/Sites/Ops/_vti_bin/Lists.asmx?WSDL作为Web引用时,我可以调用这些方法并获得有效的响应。
当我引用与服务引用相同的url时,服务器在调用方法时会引发异常。
我的帐户在Sharepoint Farm中是admin。
这是服务引用(主要是自动生成)在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>
Saddly,异常提供了唯一的信息是这样的:
“类型的Microsoft.SharePoint程序“异常.SoapServer.SoapServerException'被引发。“
没有其他的细节。
,我正在使用的代码是:
public ListClass()
{
_Client = new SharepointLists.ListsSoapClient();
}
public System.Xml.Linq.XElement GetTaskList()
{
return _Client.GetList("Tasks");
}
有什么想法?我想使用服务引用而不是Web引用。
UPDATE:
我想罗布的建议,并得到这个错误:
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').'.
添加服务引用对话框不会生成一个ASMX服务的正确配置。你需要使用svcutil代替。
本博客文章应该可以帮助您http://nayyeri.net/integrating-wcf-clients-with-asmx-services
@Rob我感谢您的建议抢,可惜这没有奏效。我更新了错误信息。 – 2010-03-16 02:51:52
(迟来的错误修复和downvote)@Rob:-1:该博客帖子是从2007年开始的。“添加服务引用”与ASMX Web服务或任何其他基本SOAP Web服务非常协调。它只是使用basicHttpBinding。 – 2012-03-24 15:50:30