В WCF нам следует настроить дополнительную конечную точку службы для протокола HTTPS
, для которого требуется режим безопасности транспортного уровня.
<services>
<service name="WcfService1.Service1">
<!--please pay attention to that apply the binding configuration by means of bindingConfiguration property.-->
<endpoint address="" binding="basicHttpBinding" contract="WcfService1.IService1" bindingConfiguration="mybinding"></endpoint>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"></endpoint>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="mybinding">
<security mode ="Transport">
<transport clientCredentialType="None"></transport>
</security>
</binding>
</basicHttpBinding>
</bindings>
Приведенная ниже конфигурация поддерживает протокол HTTP и протокол HTTPS.
<system.serviceModel>
<services>
<service name="WcfService1.Service1">
<!--please pay attention to that apply the binding configuration by means of bindingConfiguration property.-->
<endpoint address="" binding="basicHttpBinding" contract="WcfService1.IService1" bindingConfiguration="mybinding"></endpoint>
<endpoint address="" binding="basicHttpBinding" contract="WcfService1.IService1"></endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"></endpoint>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="mybinding">
<security mode ="Transport">
<transport clientCredentialType="None"></transport>
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpsGetEnabled="true" httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
Мы также можем использовать секцию ProtocolMapping
для упрощения конфигурации. Приведенная ниже конфигурация поддерживает протоколы HTTP и HTTPS.
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpsGetEnabled="true" httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<protocolMapping>
<add binding="basicHttpBinding" scheme="http"/>
<add binding="basicHttpsBinding" scheme="https"/>
</protocolMapping>
</system.serviceModel>
Официальный документ.
https://docs.microsoft.com/en-us/dotnet/framework/wcf/simplified-configuration
Не стесняйтесь сообщить мне, если я чем-нибудь могу помочь с.