This subject is discussed several times here, but even after reading Microsoft documentation https://learn.microsoft.com/en-us/dotnet/framework/wcf/configuring-services-using-configuration-files and How can I combine the WCF services config for both http and https in one web.config?
I still do not quite get how the WCF service on all its attributes works, and can not get my service to support both protocols.
I can get the service to support either HTTP or HTTPS with no problem, the issue here is to make the service choose the correct protocol by itself.
The key point is the binding protocol on the first endpoint, any other changes like the ones shown further down had no impact.
The App.config-
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
The bindings -
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="AccountServicePortSoap11"/>
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
<message algorithmSuite="Default" />
</security>
</binding>
<binding name="AccountServicePortSoap22" />
<security mode="Transport">
<transport clientCredentialType="Window" proxyCredentialType="None" realm=""/>
<message algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
The ending points-
<client>
<endpoint address="" bindingConfiguration="AccountServicePortSoap11" binding="basicHttpBinding" contract="AccountServiceRef.AccountServicePort" name="AccountServicePortSoap11" />
<endpoint address="" bindingConfiguration="AccountServicePortSoap22" binding="basicHttpBinding" contract="AccountServiceRef.AccountServicePort" name="AccountServicePortSoap22" />
</client>
Rest of App.config
<appSettings>
<add key="defaultServer" value="http://**.**.**.**:80 " />
</appSettings>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="DocumentFormat.OpenXml" publicKeyToken="******" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.8.1.0" newVersion="2.8.1.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Changes that I have tried-
<serviceBehaviors>
<behavior name="MyServiceBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
<protocolMapping>
<add scheme="http" binding="basicHttpBinding" bindingConfiguration="AccountServicePortSoap22"/>
<add scheme="https" binding="basicHttpBinding" bindingConfiguration="AccountServicePortSoap11"/>
</protocolMapping>
<services>
<service behaviorConfiguration="MyServiceBehavior" name="com.advantage.online.store.accountservice" >
<endpoint address="" binding="basicHttpBinding" contract="AccountServiceRef.AccountServicePort" name="AccountServicePortSoap11" />
<endpoint address="" binding="basicHttpBinding" contract="AccountServiceRef.AccountServicePort" name="AccountServicePortSoap22" />
</service>
</services>