I have a WCF data service self hosted in a console application. It runs without complains and when security is set to "None" it works like a charm. Now, when I enable transport security, it still runs, but when I hit the url in the web browser it doesn't find it. I'm using a self signed certificate to test it.
I would appreciate any help and advice.
Thank you in advance.
Here is my app.config:
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</modules>
<handlers>
<add name="UrlRoutingHandler" preCondition="integratedMode" verb="*" path="UrlRouting.axd"/>
</handlers>
</system.webServer>
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="TransportSecurity" >
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
<!--<security mode="None"/>-->
</binding>
</webHttpBinding>
</bindings>
<services>
<service name="ConsoleServiceHost.BooksDataService">
<host>
<baseAddresses>
<add baseAddress="https://localhost:8900" />
</baseAddresses>
</host>
<endpoint address="BooksDataService" binding="webHttpBinding" bindingConfiguration="TransportSecurity" behaviorConfiguration="webHttpBehavior" contract="System.Data.Services.IRequestHandler"></endpoint>
<!--<endpoint address="mex" binding="mexHttpsBinding" name="mex" contract="IMetadataExchange" />-->
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="SSLBehave">
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceCredentials>
<serviceCertificate findValue="a3 6f 22 85 86 09 f0 4b 12 3c ea 18 10 c7 14 63 32 f8 a0 6e" storeLocation="LocalMachine" storeName="My" x509FindType="FindByThumbprint" />
</serviceCredentials>
<useRequestHeadersForMetadataAddress>
<defaultPorts>
<add scheme="https" port="443"/>
</defaultPorts>
</useRequestHeadersForMetadataAddress>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="webHttpBehavior">
<webHttp defaultOutgoingResponseFormat="Json" defaultBodyStyle="Wrapped"/>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
...
</configuration>
Here is my service code:
public class BooksDataService : DataService<SampleDbEntities>
{
public static void InitializeService(DataServiceConfiguration config)
{
config.SetEntitySetAccessRule("*", EntitySetRights.All);
config.SetServiceOperationAccessRule("*", ServiceOperationRights.All);
config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
}
}
And here is the code to host it:
static void Main()
{
var host = new DataServiceHost(typeof(BooksDataService), new Uri[0]);
host.Open();
Console.WriteLine(host.BaseAddresses[0]);
Console.ReadKey();
host.Close();
}