다음을 통해 공유


WCF 4: AddDefaultEndpoints

Note: Cross posted from Sajay.
Permalink

Here is another little goodie we have which will help in reducing configuration. You can use the ServiceHostBase.AddDefaultEndpoints which will pretty much probe your service implementation for contracts and expose them as shown below. Notice that I don't need to specify anything more than the base address and the type of the service and I have actually commented out the call to the API. You can find more details about the simplified configuration here.

const string address = "net.tcp://localhost:8080/";
const string address2 = "https://localhost:8081/";
ServiceHost host = new ServiceHost(typeof(Service1), new Uri(address), new Uri(address2));
//host.AddDefaultEndpoints();
host.Open();

 

AddDefaultEndpoints