3

我有 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="nyc\pc" />
                </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="nyc\pc" />
        </identity>
      </endpoint>
</client>

我不知道我哪里错了。

4

2 回答 2

0

您必须将所有内容移至 Web.config 才能使其正常工作,因为它是托管服务的 Web 应用程序。

于 2015-04-23T20:07:04.517 回答
0

解决您的问题,调用项目需要具有相同的服务配置。只需将该<System.ServiecModel />部分复制到您的网站 Webconfig 中即可。此外,您可能需要在存储库中复制相同的设置。

于 2016-09-22T07:09:56.837 回答