【问题标题】:WCF Service Configuration Does Not Work in IISWCF 服务配置在 IIS 中不起作用
【发布时间】:2020-06-11 02:51:53
【问题描述】:

我有一个托管在 IIS8 中的 WCF 服务,在 Windows8 中,我使用框架 4.5,我尝试根据文档添加端点,但是有一部分我不清楚;参数是什么意思:

<add baseAddress="http://localhost:808/Wcf_ProyectName/ClassServive.svc"/> 

您可以在下一个视频中看到详细信息:

https://www.youtube.com/watch?v=b6wZhuOdzGQ&feature=youtu.be

无论改变多少值都不适用。我的配置完成了:

    <?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
  </system.web>
  <system.serviceModel>
<services>
<service name="Wcf_ProyectName.MiServiceName">
        <host>  
          <baseAddresses>  
            <add baseAddress="http://localhost:808/Wcf_ProyectName/MiServiceName.svc"/>  
          </baseAddresses>  
        </host> 
        <endpoint address="MiServiceName" binding="basicHttpBinding" contract="Wcf_ProyectName.IMiServiceName">          
        </endpoint>
      </service>
</services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- Para evitar revelar información de los metadatos, establezca los valores siguientes en false antes de la implementación -->
          <serviceMetadata httpGetEnabled="true" />
          <!-- Para recibir detalles de las excepciones en los fallos, con el fin de poder realizar la depuración, establezca el valor siguiente en true. Para no revelar información sobre las excepciones, establézcalo en false antes de la implementación -->
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
    <!--
        Para examinar el directorio raíz de la aplicación web durante la depuración, establezca el valor siguiente en true.
        Establézcalo en false antes de la implementación para evitar revelar información sobre la carpeta de aplicación web.
      -->
    <directoryBrowse enabled="false" />
  </system.webServer>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
  <connectionStrings>
    <add name="AlmacenDB" connectionString="server=.\WIN8R2;database=AlmacenDB;integrated security=True;" providerName="System.Data.SqlClient" />
  </connectionStrings>
</configuration>

【问题讨论】:

    标签: wcf wcf-binding


    【解决方案1】:

    根据您的描述,我发现当您将服务发布到IIS时,您的配置文件中仍然存在host标签。只有像 Windows 服务这样的自托管或托管程序需要配置主机。在 IIS 中托管服务时,服务的基地址由 IIS 中部署的端口号和服务的文件名组成。

    这是部署在 IIS 中的 WCF 服务的配置文件。

    有关IIS中WCF部署的更多详细信息,请参考以下链接:

    WCF / EF / SQL Server / VS2017 / C# : multi-tier application gets error when deployed to local IIS 10.0 as hosting server

    【讨论】:

    • 好的,谢谢,但我不知道为什么当我尝试对数据库执行操作时,它会抛出错误'初始化数据库时发生异常。有关详细信息,请参阅 InnerException 提到的帖子链接中也没有解决它的问题
    • 最后我选择更改我的连接字符串,在我的电脑上通过用户身份更改应用程序池
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-10-04
    • 1970-01-01
    • 2019-05-24
    • 1970-01-01
    • 1970-01-01
    • 2011-12-20
    • 2011-09-07
    相关资源
    最近更新 更多