我有mvc Web项目,我添加了另一个空项目,它包含所有服务,更像存储库。
所以我遇到了它抛出错误的问题,即使我在 Web.config 中添加了绑定,我也无法弄清楚为什么。
错误:
在 ServiceModel 客户端配置部分中找不到引用协定"DataService.ISDService"的默认终结点元素。这可能是因为找不到应用程序的配置文件,或者因为在客户端元素中找不到与此协定匹配的终结点元素。
应用配置:
<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="SDEndPoint" />
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://services.local.com/Api.svc/wsHttp"
binding="wsHttpBinding" bindingConfiguration="SDEndPoint"
contract="ImageService.ISDService" name="SDEndPoint">
<identity>
<userPrincipalName value="nycpc" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
网络配置:
<client>
<endpoint address="http://services.local.com/Api.svc/wsHttp" binding="wsHttpBinding" bindingConfiguration="SDEndPoint" contract="ImageService.ISDService" name="SDEndPoint">
<identity>
<userPrincipalName value="nycpc" />
</identity>
</endpoint>
</client>
我不知道我哪里出错了。
您必须将所有内容向下移动到 Web.config 才能使其正常工作,因为它是托管服务的 Web 应用程序。
为了解决您的问题,调用项目需要对服务具有相同的配置。只需将<System.ServiecModel />
部分复制到您的网站Webconfig中即可。此外,您可能需要复制存储库中的相同设置。