WCF System.ServiceModel.EndpointNotFoundException - PullRequest
0 голосов
/ 28 ноября 2018

Я создал службу wcf - когда я пытался подключиться из «отладочного» приложения MS для тестирования, все выглядит нормально, когда я делал свое собственное приложение, я всегда получаю ошибку System.ServiceModel.EndpointNotFoundException.Где проблема?

Это настройки приложения:

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

Правильно ли установлена ​​конечная точка?

1 Ответ

0 голосов
/ 29 ноября 2018

Как вы знаете, адрес конечной точки состоит из базового адреса и относительного адреса.IIS размещает приложение WCF по умолчанию, когда мы отлаживаем приложение.IIS определяет базовый адрес, и мы должны указать относительный адрес службы в файле конфигурации:

  <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 будет указывать базовый адрес.enter image description here
Если мы размещаем приложение wcf в IIS, базовый адрес конечной точки обычно формируется из файла svc.enter image description here
Таким образом, базовый адрес http://172.17.16.82:9001/service1.svc
Не стесняйтесь, сообщите мне, если есть что-то, с чем я могу помочь.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...