I am working through a REST services book dealing with WCF. I have been following along the examples and relize that the configuration of WCF seems like a tough thing to master. I have a piece of code below and configures and opens an endpoint. I know that this is an old school 3.0 way to accomplish this RESTful task but am wondering how I could set this up in the app config instead any ideas? Also does anyone know any sites that breakdown the WCF configurations in code/config in a reasonable manner? Most places I have been looking show only specific examples.
CustomBinding b = new CustomBinding();
TextMessageEncodingBindingElement msgEncoder = new TextMessageEncodingBindingElement();
msgEncoder.MessageVersion = MessageVersion.None;
b.Elements.Add(msgEncoder);
HttpTransportBindingElement http = new HttpTransportBindingElement();
b.Elements.Add(http);
ServiceHost sh = new ServiceHost(typeof(SimpleHTTPService));
ServiceEndpoint se = sh.AddServiceEndpoint(typeof(SimpleHTTPService),
b,
"http://localhost:8889/TestHttp");
sh.Open();
If you want to define that endpoint in config, it would look like the config below. Notice that this isn’t enough to emulate the REST programming model in 3.0 (remember that this only sets the binding; on 3.5 and above you only need to set a behavior)