我写了一些运行良好(安静)的wcf网络服务。 我现在需要支持仅从https
调用这些Web服务配置文件代码:
<service name="Microsoft.ServiceModel.Samples.CalculatorService" behaviorConfiguration="CalculatorServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8000/ServiceModelSamples/service"/>
</baseAddresses>
</host>
<endpoint address="" binding="wsHttpBinding" contract="Microsoft.ServiceModel.Samples.ICalculator" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="CalculatorServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="False"/>
</behavior>
</serviceBehaviors>
</behaviors>
答案 0 :(得分:1)
以下是您可以启用SSL的步骤。
现在你的wcf配置文件就像这样
<system.serviceModel>
<services>
<service name="NorthwindServices.ProductService">
<endpoint address=""
binding="basicHttpBinding"
bindingConfiguration="secureHttpBinding"
contract="NorthwindServices.IProducts"/>
<endpoint address="mex"
binding="mexHttpsBinding"
contract="IMetadataExchange" />
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="secureHttpBinding">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
注意我已经改变了以下内容
1)在serviceBehaviors中,为了允许https请求,我设置了httpsGetEnabled="true"
。
2)将clientCredentialType
设置为None以指定不执行客户端验证的匿名身份验证。 clientCredentialType的可能值为None, Basic, Digest, Ntlm, Windows
。
最后,您可以在IIS中托管服务。
在IIS中右键单击该站点,然后单击“编辑绑定”,现在单击“添加” 按钮并从“添加站点绑定”窗口的类型下拉列表中选择“https”。 从SSL证书下拉列表中选择您在第一步中创建的testcertificate。单击“确定”并关闭“站点绑定”窗口。
在localhost中发布wcf。