简体   繁体   中英

Could not find default endpoint element that references contract in WCF

I've mvc web project and I have added another empty project which holds all the services more like repository.

So I'm having issue where it throws error and I can't figure it out why even though I have added bindings in Web.config.

Error:

Could not find default endpoint element that references contract 'DataService.ISDService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.

App.config:

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

Web.config:

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

I can't figure out where I'm going wrong.

为了使其正常工作,您必须将所有内容都移到Web.config上,因为托管该服务的是Web应用程序。

The solve your problem, the calling project needs to have the the same configuration for the services. Just copy the <System.ServiecModel /> part into your website Webconfig. Also, you may need to copy the same settings in the repository.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM