简体   繁体   中英

Facing issue with WCF: Could not find default endpoint

I created a WCF service in separate project name is AaWs then added this project in a website project as a reference . website project name is AaNuWs

in website project web.config file is

  <system.web>
    <compilation debug="true" />
  </system.web>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="mexBehavior">
          <serviceMetadata httpGetEnabled="True"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service behaviorConfiguration="mexBehavior" name="AaWs.RxtraIntroService">
        <endpoint address ="AaWs" binding="basicHttpBinding" contract="AaWs.IRxIntro">
        </endpoint>
        <host>
          <baseAddresses>
            <add baseAddress = "http://localhost:8080" />
          </baseAddresses>
        </host>
      </service>
    </services>
  </system.serviceModel>
</configuration>

then uploaded this website project on my web server.

then give the service reference in my new project from my website with a name space

IntroService

http://mywebsite/IntroService.svc?wsdl

new system create a new app.config file for me

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_IRxIntro" />
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://mywebsite/IntroService.svc/RecoverInfoTechAaWs"
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IRxIntro"
                contract="IntroService.IRxIntro" name="BasicHttpBinding_IRxIntro" />
        </client>
    </system.serviceModel>
</configuration> 

but now when i trying to access this service i am getting a error.

System.InvalidOperationException: Could not find default endpoint element that references contract 'IntroService.IRxIntro' 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.

please help me on this

You need to confirm that the app.config is in the root folder with your executable. Then confirm that the app.config has the proper value for:

<client>
 <endpoint ... contract=""

From the information you provided, the address information does not look correct. Your service has an overall address of " http://localhost:8080/AaWs " but your service reference (wsdl url) shows " http://mywebsite/IntroService.svc?wsdl ". You surely want to make sure that you are pointing to the correct service when generating the reference.

从app.config的端点配置中删除name =“ BasicHttpBinding_IRxIntro”属性。

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