I'm using .NET 4 WCF to expose the following REST-full webservice
[OperationContract]
[WebGet]
void Test();
Since this is a developer oriented program, I want to support REST-full HTTP developers and also developers that like to use a WSDL. My approach is to declare the service twice to expose both a traditional WSDL and also a REST endpoint:
Web.config
<serviceHostingEnvironment aspNetCompatibilityEnabled="True" multipleSiteBindingsEnabled="true" >
<serviceActivations >
<add relativeAddress ="~/KeyService.svc" service="SecretDistroMVC3.Services.KeyService3"/>
</serviceActivations>
</serviceHostingEnvironment>
Global.asax
void Application_Start(object sender, EventArgs e)
{
// The following enables the WCF REST endpoint
//ASP.NET routing integration feature requires ASP.NET compatibility. Please see
// 'http://msdn.microsoft.com/en-us/library/ms731336.aspx
RouteTable.Routes.Add(new ServiceRoute("KeyService3", new WebServiceHostFactory(), typeof(KeyService3)));
Question
Since I don't like to have the service declared in two locations, how do I either configure both endpoints in config, or both endpoints in Application_Start
?
Examples