Answered by:
How do you change the default protocol mapping in Beta 2?

Question
-
I am using VS 2010 Beta 2. I want to host a WCF service in IIS, so I add a new Web site to my solution and I use the WCF Service template. In the Web.config there are no endpoints defined and so I use the default endpoint. The service is hosted using BasicHttpBinding.
In Beta 1, I could specify that I want to use WsHttpBinding rather than BasicHttpBinding as the default. I did this by modifying the protocolMapping section in machine.config.
But in Beta 2, there is no protocolMapping section in my machine.config. How do I change the default protocol mapping?
RobertTuesday, November 10, 2009 5:56 PM
Answers
-
You can add the config code that I wrote before in any level of the config hierarchy you want. If you want to use WsHttpBinding for a particular service, then change its web.config/app.config. If you want to change several services to use WsHttpBinding for their default endpoint, add a new hierarchical level so the change in the procol mapping table affect to several services in your machine, but not to all.
If you add that in machine.config then all your services using default endpoints will use WsHttpBinding for HTTP. The performance hit comes when services that have explicit configuration will need to parse the protocol mapping in machine.config, even though they will never use it. Perhaps this is not an issue for you though, if all your services use default endpoints.
Also, for this matter, there should not be any difference between having an app.config (selfhosted app) or a web.config (webhosted app).- Marked as answer by Robert Green Tuesday, November 10, 2009 8:00 PM
Tuesday, November 10, 2009 7:53 PMModerator
All replies
-
The protocol mapping table has been removed from machine.config in Beta 2 because of performance reasons. But the default protocol mappings are the same than in Beta 1. Instead of changing your machine.config (you should try to never touch that file, since that will affect every single service in your machine), you should add the following in your service web.config/app.config:
<system.serviceModel> <protocolMapping> <add scheme="http" binding="wsHttpBinding"/> </protocolMapping> </system.serviceModel>
That will override the default mapping for HTTP and then your service will use WsHttpBinding in its default endpoint instead of BasicHttpBinding.
Also, for some more explanation about this, you can read this blog post: http://blogs.msdn.com/endpoint/archive/2009/06/30/service-configuration-improvements-in-net-4.aspx- Proposed as answer by Amadeo Casas - MSFTModerator Tuesday, November 10, 2009 7:03 PM
Tuesday, November 10, 2009 7:01 PMModerator -
I see. But now I don't have a way of easily changing the default from Basic to WS. I have to override the default in each host app rather than just deciding up front that I want to use WsHttpBinding as my default.
In addition, if I self-host a service, I now have to have an app.config file.
As I was playing with this, I added the protocolMapping to machine.config and that changed the default to WSHttpBinding. I understand that is not now recommended, but it does work. How much of a perf hit am I going to take?
RobertTuesday, November 10, 2009 7:34 PM -
You can add the config code that I wrote before in any level of the config hierarchy you want. If you want to use WsHttpBinding for a particular service, then change its web.config/app.config. If you want to change several services to use WsHttpBinding for their default endpoint, add a new hierarchical level so the change in the procol mapping table affect to several services in your machine, but not to all.
If you add that in machine.config then all your services using default endpoints will use WsHttpBinding for HTTP. The performance hit comes when services that have explicit configuration will need to parse the protocol mapping in machine.config, even though they will never use it. Perhaps this is not an issue for you though, if all your services use default endpoints.
Also, for this matter, there should not be any difference between having an app.config (selfhosted app) or a web.config (webhosted app).- Marked as answer by Robert Green Tuesday, November 10, 2009 8:00 PM
Tuesday, November 10, 2009 7:53 PMModerator -
Thanks Amadeo
Tuesday, November 10, 2009 8:00 PM