Achim
Achim

Reputation: 15702

Configure WCF kind="webHttpEndpoint" via code

I have a WCF service, which implements interface PosData.ISampleService in class PosData.SampleService. The service is self hosted and the start up code looks like this:

ServiceHost serviceHost = new ServiceHost(typeof(SampleService), new Uri("http://localhost:8080/sample"));
serviceHost.Open();
Console.WriteLine("Service started.");
Console.ReadLine();

The app.config contains the following lines:

<services>
  <service name="PosData.SampleService">
    <endpoint address="http://localhost:8080/sample" contract="PosData.ISampleService" kind="webHttpEndpoint"/>
  </service>
</services>

I would like to get rid of the App.config configuration, but I have no idea how to configure webHttpEndpoint via code. How can I do that?

Upvotes: 1

Views: 737

Answers (1)

Phil Degenhardt
Phil Degenhardt

Reputation: 7264

Use WebServiceHost instead of ServiceHost.

Upvotes: 2

Related Questions