【问题标题】:Facing issue with WCF: Could not find default endpointWCF面临的问题:找不到默认端点
【发布时间】:2015-04-02 13:12:42
【问题描述】:

我在单独的项目名称中创建了一个WCF 服务 AaWs 然后将此项目添加到网站项目中作为参考。网站项目名称是AaNuWs

在网站项目web.config文件中是

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

然后将此网站项目上传到我的网络服务器上。

然后在我的网站上的新项目中提供服务参考,并带有名称空间

介绍服务

http://mywebsite/IntroService.svc?wsdl

新系统为我创建一个新的 app.config 文件

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

但现在当我尝试访问此服务时出现错误。

System.InvalidOperationException:找不到默认端点 引用合同“IntroService.IRxIntro”的元素 ServiceModel 客户端配置部分。这可能是因为没有 为您的应用程序找到了配置文件,或者因为没有 可以在客户端中找到与此合同匹配的端点元素 元素。

请帮帮我

【问题讨论】:

    标签: c# .net web-services wcf service


    【解决方案1】:

    您需要确认 app.config 位于可执行文件所在的根文件夹中。然后确认 app.config 具有正确的值:

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

    根据您提供的信息,地址信息看起来不正确。您的服务的总地址为“http://localhost:8080/AaWs”,但您的服务参考(wsdl url)显示“http://mywebsite/IntroService.svc?wsdl”。您一定要确保在生成引用时指向正确的服务。

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        猜你喜欢
        • 2011-04-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-02-28
        • 1970-01-01
        • 2023-02-16
        • 1970-01-01
        • 2010-09-26
        相关资源
        最近更新 更多