For configuring web.config file...
Go to tools click on WCF Service Configuration Editor
then go to solution explorer and right click on your web.config file and select edit with WCF Service Congiruation Editor
it will show nice UI to configuring service and setting up endpionts, bindings etc. So need not to write this code manually.