JoeMjr2
JoeMjr2

Reputation: 3944

WCF basicHttpsBinding warning: "is invalid according to its datatype"

I created a WCF application, starting with basicHttpBinding. In app.config, I have the following endpoint configured:

<endpoint address="" binding="basicHttpBinding" contract="JMMEcommerceService.IJMMEcommerceService">
  <identity>
    <dns value="localhost" />
  </identity>
</endpoint>

This builds fine. However, I want to change the protocol from HTTP to HTTPS. If I change the endpoint declaration to:

<endpoint address="" binding="basicHttpsBinding" contract="JMMEcommerceService.IJMMEcommerceService">
  <identity>
    <dns value="localhost" />
  </identity>
</endpoint>

(note: the only change is basicHttpBinding -> basicHttpsBinding)

I get the following warning a build time:

WCF configuration validation warning: The 'binding' attribute is invalid - The value 'basicHttpsBinding' is invalid according to its datatype 'serviceBindingType'.

Why would I get this warning? Is there something else that I need to change?

Here is the full app.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" />
  </system.web>
  <!-- When deploying the service library project, the content of the config file must be added to the host's 
  app.config file. System.Configuration does not support config files for libraries. -->
  <system.serviceModel>
    <services>
      <service name="JMMEcommerceService.JMMEcommerceService">
        <endpoint address="" binding="basicHttpsBinding" contract="JMMEcommerceService.IJMMEcommerceService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="https://localhost:8733/Design_Time_Addresses/JMMEcommerceService/JMMEcommerceService/" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, 
          set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="True" httpsGetEnabled="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="True" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

</configuration>

Upvotes: 1

Views: 6643

Answers (2)

SpecialHias
SpecialHias

Reputation: 119

If you like to enable HTTPS for your service, but not for your Metadata, you have to provide another base address for your HTTP-based Metadata Exchange endpoint.

<baseAddresses>
  <add baseAddress="https://localhost:8733/Design_Time_Addresses/JMMEcommerceService/JMMEcommerceService/" />
  <add baseAddress="http://localhost:8734/Design_Time_Addresses/JMMEcommerceService/JMMEcommerceService/" />
</baseAddresses>

Please note, that you have to assign another port too (8734). Two protocols can not use the same port!

PS: Do not forget to assign the correct certificate to the port 8733

Upvotes: 0

John Saunders
John Saunders

Reputation: 161781

The basicHttpsBinding does not appear to exist in .NET 4.0, only in 4.5. Which version of .NET are you targeting?

Upvotes: 2

Related Questions