During development of WCF communication, you can have a requirement to establish the communication over secured transport by using of SSL. In that case the transport security should be used:
<security mode="Transport">
Note that in this case in the endpoint configuration a HTTPS address has to be specified. However, if the address specified in the endpoint uses HTTP protocol instead of HTTPS InvalidOperationException is thrown:
Could not find a base address that matches scheme https for the endpoint with binding BasicHttpBinding. Registered base address schemes are [http]
This is because WCF does not permit sending of the clear password over unsecured transport. Unfortunately, in the test environment it is not always possible to install quickly the completed trusted certificate chain.
In such cases, using of HTTP and basic clear text (FOR TESTING PURPOSES ONLY) could be helpful.
This can be done if following TransportCredentialOnly security mode is used as shown:
<security mode="TransportCredentialOnly">
Following two configuration files show how this security mode can be configured and the client and server:
Server configuration file
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<!-- use appSetting to configure base address provided by host -->
<add key="baseAddress" value="http://localhost:8000/servicemodelsamples/service" />
</appSettings>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="NewBinding">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Basic" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="Microsoft.ServiceModel.Samples.CalculatorService">
<endpoint binding="basicHttpBinding" bindingConfiguration="NewBinding"
name="MyService" contract="Microsoft.ServiceModel.Samples.ICalculator" />
</service>
</services>
</system.serviceModel>
</configuration>
Client Configuration File
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="NewBinding">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Basic" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint binding="basicHttpBinding" bindingConfiguration="NewBinding"
name="MyService" contract="Microsoft.ServiceModel.Samples.ICalculator"
address="http://localhost:8000/servicemodelsamples/service"/>
</client>
</system.serviceModel>
</configuration>
Posted
Jul 31 2006, 06:00 PM
by
Damir Dobric