Could not find default endpoint element that references contract - Hosting wcf

此生再无相见时 提交于 2019-12-05 12:19:17
Edis

Copy system.serviceModel section from the app.config in your library project and put it in your web.config and refresh service reference. See also this answer. Could not find default endpoint element

Add "WSHttpBinding" end point in your WCF service web.config file like below

 <endpoint address="web" behaviorConfiguration="jsonBehavior" binding="webHttpBinding" bindingConfiguration="webHttpBindingWithJsonP" contract="DataService.IDataService"/>
 <endpoint address="" binding="wsHttpBinding" bindingConfiguration="wsHttpBinding" contract="DataService.IDataService"  />

and in your app.config file write code like below

<system.serviceModel>
<bindings>
  <wsHttpBinding>
    <binding name="WSHttpBinding_IDataService" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
      <security mode="None" />
    </binding>
  </wsHttpBinding>
</bindings>
<client>
  <endpoint address="http://localhost/pricedataservice/DataService.svc" binding="wsHttpBinding"
      bindingConfiguration="WSHttpBinding_IDataService" contract="DataService.IDataService"
      name="WSHttpBinding_IDataService" />
</client>

I am sure this will fix your problem and below blog will help you to understand different type of binding in WCF service

http://www.dotnet-tricks.com/Tutorial/wcf/VE8a200713-Understanding-various-types-of-WCF-bindings.html

Add client definition in your client web.config file like below;

 <system.serviceModel>
  /////
 <client>
         <endpoint  address="referencedurl"
          binding="webHttpBinding" bindingConfiguration=""
          contract="MemberService.IMemberService"
          name="MemberServiceEndPoint"
          behaviorConfiguration="Web">
      </endpoint>
 </client> 
////
 </system.serviceModel>

AND Service Reference Name must same as the Interfaces prefix. contract="ReferenceName.IMemberService"

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!