WCF System.ServiceModel.EndpointNotFoundException [英] WCF System.ServiceModel.EndpointNotFoundException

查看:29
本文介绍了WCF System.ServiceModel.EndpointNotFoundException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了 wcf 服务 - 当我尝试从调试"MS 应用程序进行连接以进行测试时,当我执行自己的应用程序时,一切看起来都很好,但我总是收到 System.ServiceModel.EndpointNotFoundException 错误.哪里出了问题?

I created wcf service - when i tried to connect from "debug" MS application for testing, everything looks okay when i did my own application, I always get the System.ServiceModel.EndpointNotFoundException error. Where is a problem?

这是应用程序设置:

<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 设置:

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

端点设置正确吗?

推荐答案

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

As you know, the endpoint address consists of a base address and a relative address. IIS host the WCF application by default when we debug the application. IIS specifies the base address, and we should specify the relative address of the service in the configuration file,

  <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
如果有什么我可以帮忙的,请随时告诉我.

If we debug the application in Visual Studio. the IIS Express will specify the base address.
If we host the wcf application in IIS, an endpoint base address is usually formed with the svc file.
So the base address is http://172.17.16.82:9001/service1.svc
Feel free to let me if there is anything I can help with.

这篇关于WCF System.ServiceModel.EndpointNotFoundException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆