首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >WCF System.ServiceModel.EndpointNotFoundException

WCF System.ServiceModel.EndpointNotFoundException
EN

Stack Overflow用户
提问于 2018-11-28 20:44:25
回答 1查看 1K关注 0票数 1

我创建了wcf服务-当我尝试从“调试”MS应用程序进行测试时,当我创建自己的应用程序时,一切看起来都很正常,我总是得到System.ServiceModel.EndpointNotFoundException错误。问题出在哪里?

这是应用程序设置:

代码语言:javascript
复制
<system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="IGlobalServices" />
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:53966/GlobalServices.svc/"
        binding="basicHttpBinding" bindingConfiguration="IGlobalServices"
        contract="ServiceReference1.IGlobalServices" name="IGlobalServices" />
    </client>
  </system.serviceModel>

这是wcf设置:

代码语言:javascript
复制
    <?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections>
  <connectionStrings configSource="connectionStrings.config" />
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5.2" />
    <httpRuntime targetFramework="4.5.2" />
  </system.web>
  <system.serviceModel>
    <behaviors>
      <endpointBehaviors>
        <behavior>
          <dataContractSerializer maxItemsInObjectGraph="10000000" />
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
    <bindings>
      <basicHttpBinding>
        <binding name="GlobalServicePortSoapBinding"></binding>
      </basicHttpBinding>
    </bindings>
    <services>
      <service name="Telmax.Eshop.WCFGlobal.GlobalServices">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:53966/GlobalServices.svc" />
          </baseAddresses>
        </host>
      </service>
    </services>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
    <!--
        To browse web app root directory during debugging, set the value below to true.
        Set to false before deployment to avoid disclosing web app folder information.
      -->
    <directoryBrowse enabled="true" />
  </system.webServer>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="mssqllocaldb" />
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

端点设置正确吗?

EN

回答 1

Stack Overflow用户

发布于 2018-11-29 14:54:14

正如您所知道的,端点地址由基地址和相对地址组成。当我们调试应用程序时,IIS默认承载WCF应用程序。IIS指定基址,我们应该在配置文件中指定服务的相对地址。

代码语言:javascript
复制
  <system.serviceModel>
    <services>
      <service name="WcfServiceFile.Service1">
        <endpoint address="myservice" binding="webHttpBinding" contract="WcfServiceFile.IService1" behaviorConfiguration="beh">
        </endpoint>
        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <bindings>

如果我们在Visual Studio中调试应用程序。IIS Express将指定基地址。

如果我们在IIS中托管wcf应用程序,端点基址通常由svc文件构成。

因此,基地址是http://172.17.16.82:9001/service1.svc

如果有什么我能帮上忙的,请随时告诉我。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53519793

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档