我继承了一个在IIS下托管的WCF项目。它是常规网站的一部分,即也有人类可用的页面。
该站点在IIS中配置了以下2个绑定:
1:https://www.example.com/ 2:http://www.example.com:8080/
如果我访问http://www.example.com:8080/my-service.svc?wsdl,我会按预期返回一个WSDL文件。
如果我访问https://www.example.com/my-service.svc?wsdl我被告知我需要访问http://www.example.com:8080/my-service.svc?wsdl来创建客户。
web.config中的system.serviceModel下没有绑定部分。
我想知道的是,服务如何知道它与第二个IIS
绑定相关联,而不是第一个绑定。
system.ServiceModel如下:
<system.serviceModel>
<extensions>
<behaviorExtensions>
<add name="FormsAuthBehavior" type="My-WCF.FormsAuthBehaviorExtensionElement, EcobuttonWebService" />
</behaviorExtensions>
</extensions>
<behaviors>
<serviceBehaviors>
<behavior name="FormsAuthenticated">
<!--To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment-->
<serviceMetadata httpGetEnabled="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" />
<!--Pre-authenticates client with server to generate FormsAuthentication cookie. Cookie is submitted with each WCF request.-->
<!--NB: set throwsSecurityExceptions="false" when updating service references in client apps.-->
<FormsAuthBehavior throwsSecurityExceptions="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" />
<services>
<service name="My-Service" behaviorConfiguration="FormsAuthenticated" />
</services>
</system.serviceModel>
答案 0 :(得分:0)
为HTTP传输安全配置WCF服务
<bindings>
<basicHttpBinding>
<binding name="secureHttpBinding">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
指定您的服务和服务端点,如以下XML所示。
<services>
<service name="MySecureWCFService.Service1">
<endpoint address=""
binding="basicHttpBinding"
bindingConfiguration="secureHttpBinding"
contract="MySecureWCFService.IService1"/>
<endpoint address="mex"
binding="mexHttpsBinding"
contract="IMetadataExchange" />
</service>
</services>
启用httpsGetEnabled
<serviceBehaviors>
<serviceMetadata httpsGetEnabled="true"/>
</serviceBehaviors>
<强>参考文献:强>
<强> MSDN 强>
<强> Seven simple steps to enable HTTPS on WCF WsHttp bindings 强>