我正在尝试在https服务器上托管WCF REST服务。服务器上的IIS管理器已配置为https端口的属性,并且我的Web.config已正确配置。但是,我在ping通URL时仅收到此消息“'/'应用程序错误中的服务器错误”。该URL与已配置为IIS应用程序的正确虚拟目录匹配。它只是无法解决。我在此服务器上有另一个运行良好的WCF服务,但由于它是肥皂服务,所以正在使用basicHttpBinding。
有人可以看看我的RESTful web.Config并查看我是否已经看过某些东西了,因为肯定有问题吗?如果在不使用所有https配置设置的情况下使用http部署到我的本地计算机上,则该服务可以正常工作,但是在其他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>
答案 0 :(得分:1)
在我看来,您的服务配置文件没有问题。它仅支持Https协议。托管环境中可能存在一些问题。
我们应该在IIS绑定模块中提供https绑定,则服务地址将为https://x.x.x.x:xxxxx/service1.svc
此外,这是我使用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
随时让我知道是否有什么可以帮助您的。