使用https的WCF REST服务的“/”应用程序错误中的服务器错误

问题描述 投票:0回答:1

我正在尝试在https服务器上托管WCF REST服务。服务器上的IIS管理器已配置https端口的属性,并且我的Web.config已正确配置。但是,我只是在ping URL时收到此消息“服务器错误'/'应用程序错误”。 URL匹配已配置为IIS应用程序的正确虚拟目录。它只是没有解决。我在这台运行良好的服务器上有另一个WCF服务,但它使用basicHttpBinding,因为它是一个soap服务。

有人可以看看我的RESTful web.Config,看看我是否已经看过一些东西,因为一定有什么问题?使用http在没有所有https配置设置的情况下在本地计算机上部署此服务时可以正常工作,但是当部署在另一个https服务器上时,它不起作用。必须有一些我想念的东西。 TNX。

    <?xml version="1.0"?>
    <configuration>
      <appSettings>
      </appSettings>
      <!-- SQL connection settings -->
      <connectionStrings>
      </connectionStrings>
      <!--
        For a description of web.config changes see http://go.microsoft.com/fwlink/?LinkId=235367.

        The following attributes can be set on the <httpRuntime> tag.
          <system.Web>
            <httpRuntime targetFramework="4.6" />
          </system.Web>
      -->
      <system.web>
        <compilation debug="true" targetFramework="4.6"/>
        <httpRuntime targetFramework="4.5"/>
      </system.web>
      <system.serviceModel>
        <client/>

        <bindings>
          <webHttpBinding>
            <binding name="secureHttpBinding" maxReceivedMessageSize="200000000">
              <security mode="Transport">
                <transport clientCredentialType="None"/>
              </security>
            </binding>
          </webHttpBinding>
          <mexHttpsBinding>
            <binding name="secureMexBinding"/>
          </mexHttpsBinding>
        </bindings>

        <behaviors>
          <!-- Required for json web service -->
          <endpointBehaviors>
            <behavior name="webBehavior">
              <webHttp/>
            </behavior>
          </endpointBehaviors>

          <serviceBehaviors>
            <behavior name="serviceBehaviors">
              <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
              <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true"/>
              <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
              <serviceDebug includeExceptionDetailInFaults="false"/>
            </behavior>
          </serviceBehaviors>

        </behaviors>
        <services>
          <service behaviorConfiguration="serviceBehaviors" name="RepoWebService.MasterRepoAPI">
            <endpoint address="" behaviorConfiguration="webBehavior" binding="webHttpBinding" bindingConfiguration="secureHttpBinding" contract="StatuteRepoWebService.IRepoWebService.MasterRepoAPI"/>
            <endpoint address="mex" binding="mexHttpsBinding" bindingConfiguration="secureMexBinding" contract="IMetadataExchange"/>
          </service>
        </services>
        <protocolMapping>
          <add scheme="https" binding="webHttpBinding" bindingConfiguration="secureHttpBinding"/>
        </protocolMapping>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
      </system.serviceModel>
      <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"/>
      </system.webServer>
      <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
            <bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0"/>
          </dependentAssembly>
        </assemblyBinding>
      </runtime>
    </configuration>
c# wcf
1个回答
1
投票

在我看来,您的服务配置文件没有问题。它只支持Https协议。托管环境可能存在一些问题。 我们应该在IIS绑定模块中提供https绑定,然后服务地址将是https://x.x.x.x:xxxxx/service1.svc enter image description here 此外,这是我使用WCF4.5新功能协议映射的简化配置。它支持https和http。

<system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior>
          <webHttp />
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <bindings>
      <webHttpBinding>
        <binding name="mybinding">
          <security mode="Transport">
            <transport clientCredentialType="None"></transport>
          </security>
        </binding>
      </webHttpBinding>
    </bindings>
    <protocolMapping>
      <add binding="webHttpBinding" scheme="http"/>
      <add binding="webHttpBinding" scheme="https" bindingConfiguration="mybinding"/>
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>

https://docs.microsoft.com/en-us/dotnet/framework/wcf/whats-new 如果有什么我可以帮忙,请随时告诉我。

© www.soinside.com 2019 - 2024. All rights reserved.