I am totally new to WCF and I am still learning the basics. What I've learned so far was that I can create a service and configure its endpoints and behaviors in the service's config file. And when I run my service through visual studio, a default application will be created and the service will be hosted in IIS successfully and everything works great.
Now when I create a host application for my service, I figured out that I should add the service endpoints (and behaviors) for my service again in the code as following:
ServiceHost host = new ServiceHost(typeof(HelloService));
host.AddServiceEndpoint(typeof(IHelloWorld),
new WSHttpContextBinding(),
"http://localhost:8873/helloworld/ws");
host.Open();
foreach (var se in host.Description.Endpoints)
{
Console.WriteLine(se.Address);
}
host.Close();
Console.Read();
or I can do it in the host application's config file
So here are my question :
what is the point of defining endpoints in service's own config file when it is not even useful in a host application?
Or is it that service's config file only applies to IIS and managed hosts only?
and finally is there a way to have the service's own configurations in the host application (not defining the endpoints and behaviors in the host application again) or the two mentioned configurations are completely different?
EDIT
my ultimate question is that how can I use the configurations defined in service's config file in the host application?(Without using host application's own config file or creating additional code to define new endpoints and behaviors )