Reputation: 716
I'm new to WCF. Yesterday I put together my first Self-hosted WCF service. Everything was going well, however I am no longer getting any HTTP response from my dev machine. I can't even get to WSDL... I was hoping somebody could take a look over my configuration please?
host.Open(); actually works, so it seems to be running okay; it's just I can't seem to browse to any of the endpoints in a web browser on the hosting machine without a 404.
Program.cs
static void Main(string[] args)
{
try
{
using (ServiceHost host = new ServiceHost(typeof(WebImageRenderer.Renderer)))
{
host.Open();
Console.WriteLine(host.BaseAddresses[0].AbsoluteUri);
}
}
catch (Exception ex) { Console.WriteLine(ex.Message); }
while (true) Console.ReadLine();
}
App.Config
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<services>
<service name="WebImageRenderer.Renderer" behaviorConfiguration="serviceBehavior">
<endpoint address="" binding="basicHttpBinding" contract="WebImageRenderer.IRenderer"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8000"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="serviceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug httpHelpPageEnabled="true" includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
Thank you all
Upvotes: 1
Views: 45
Reputation: 6541
I think your ServiceHost is closed as soon as you exit the "using" block. Try putting the ReadLine loop inside.
Upvotes: 1