IIS主机和SSL的WCF web.config文件设置
经过数小时的示例搜索,大多数示例只包含方法的片段,而不包含“全貌”,我想寻求指导。从VisualStudio使用新的WCF服务创建的现成web.config开始,我编写了我的基本web服务。在调试中运行时,WCF测试客户端将显示可以测试的函数。这太棒了。现在,为了将代码移动到IIS(首先在本地计算机上,然后在使用SSL的web服务器旁边),我添加了一些在web上找到的代码。我确实在某一点上使用了我的配置,但我成功地对其进行了大量更改,以至于丢失了原始配置。所以,我有这个:IIS主机和SSL的WCF web.config文件设置,wcf,web-config,Wcf,Web Config,经过数小时的示例搜索,大多数示例只包含方法的片段,而不包含“全貌”,我想寻求指导。从VisualStudio使用新的WCF服务创建的现成web.config开始,我编写了我的基本web服务。在调试中运行时,WCF测试客户端将显示可以测试的函数。这太棒了。现在,为了将代码移动到IIS(首先在本地计算机上,然后在使用SSL的web服务器旁边),我添加了一些在web上找到的代码。我确实在某一点上使用了我的配置,但我成功地对其进行了大量更改,以至于丢失了原始配置。所以,我有这个: <sys
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<protocolMapping>
<add scheme="http" binding="webHttpBinding"/>
</protocolMapping>
<services>
<service name="TaskTrackerAppService.Service1" behaviorConfiguration="">
<endpoint address=""
binding="webHttpBinding"
contract="TaskTrackerAppService.IAppWebService"
behaviorConfiguration="WebBehavior"></endpoint>
<endpoint address="mex" binding="mexHttpBinding"
contract="IMetadataExchange" bindingConfiguration=""></endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="WebBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="TaskTrackerAppService.IAppWebService"></binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="" binding="webHttpBinding"
bindingConfiguration="TaskTrackerAppService.IAppWebService"
contract="TaskTrackerAppService.IAppWebService"></endpoint>
</client>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
</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>
因此,我想更正web.config设置。然后部署到SSL就绪的托管IIS服务。作为奖励,是否有办法配置端点,以便我仍然可以运行调试器并获取WCF测试客户端。在once working配置中,WCF测试停止工作。它能同时支持简单配置和托管配置吗
谢谢。客户端应用程序使用
中的
部分来指定服务端点的(地址、绑定和合同)。您的桌面应用程序中应该有该部分,这样您就可以将其从服务器配置中删除
但是,桌面应用程序app.config中的
部分应具有与服务端点相同的“ABC”属性。由于您的服务绑定是webHttpBinding
,客户端也应该将webHttpBinding
作为绑定,但我可以看到它所指的绑定配置,TaskTrackerAppService.IAppWebService
实际上是一个basicHttpBinding
,因此这是一个错误配置
此外,由于您的生产环境正在使用SSL,因此您的production web.config应该具有SSL的绑定配置,如下所示:
<bindings>
<webHttpBinding>
<binding name="webBindingHTTPS">
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
</webHttpBinding>
</bindings>
使用以下端点配置:
<endpoint address=""
binding="webHttpBinding"
contract="TaskTrackerAppService.IAppWebService"
behaviorConfiguration="webBindingHTTPS"></endpoint>
实现这一点的最佳方法是使用。在这种情况下,您的版本web.config可能包含以下元素:
<bindings>
<webHttpBinding>
<binding name="webBindingHTTPS" xdt:Transform="Insert">
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
</webHttpBinding>
</bindings>
<endpoint address="" xdt:Transform="Replace" xdt:Locator="Match(name)"
binding="webHttpBinding"
contract="TaskTrackerAppService.IAppWebService"
behaviorConfiguration="webBindingHTTPS">
</endpoint>
这样,无论何时在调试模式下构建项目,都将使用OUD SSL进行配置,无论何时在发布模式下构建项目,都将使用SSL
<bindings>
<webHttpBinding>
<binding name="webBindingHTTPS" xdt:Transform="Insert">
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
</webHttpBinding>
</bindings>
<endpoint address="" xdt:Transform="Replace" xdt:Locator="Match(name)"
binding="webHttpBinding"
contract="TaskTrackerAppService.IAppWebService"
behaviorConfiguration="webBindingHTTPS">
</endpoint>