Sharepoint webpart中调用web service报错
在Sharepoint webpart中调用web service时报错
错误信息:在 ServiceModel
客户端配置部分中,找不到引用协定“PMADMWebService.PmAdmWebServiceSoap”的默认终结点元素。这可能是因为未找到应用程序的配置文件,或者是因为客户端元素中找不到与此协定匹配的终结点元素。
这是因为调用用web service的站点的web.config 中没有添加service mode 配置, 添加相关配置并重启sharepoint 站点。
在webpart工程总添加webservice引用时会在你的web part的配置文件中生成相关配置信息如下,copy整个servicemode配置节即可。
相关配置信息如下示例:
<system.serviceModel><bindings>
<basicHttpBinding>
<binding name="BasicDataWebServiceSoap" 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="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
<binding name="PmAdmWebServiceSoap" 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="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost/BasicWebService.asmx"
binding="basicHttpBinding" bindingConfiguration="BasicDataWebServiceSoap"
contract="BasicDataWebService.BasicDataWebServiceSoap" name="BasicDataWebServiceSoap" />
<endpoint address="http://localhost:8090/PmAdmWebService.asmx"
binding="basicHttpBinding" bindingConfiguration="PmAdmWebServiceSoap"
contract="PMADMWebService.PmAdmWebServiceSoap" name="PmAdmWebServiceSoap" />
</client>
</system.serviceModel>