根据网址模板

时间:2017-01-27 10:50:39

标签: c# asp.net web-services wcf odata

我正在开展Backward Compatible项目。其中, WCF 服务支持OData v1-v3。我正在构建支持OData v4的 ASP .NET Web API

我必须在这里把它们称为节目:
http://localhost:17505/api/v4/Products应调用 ASP .NET Web API 服务。 http://localhost:17505/api/v3/Products应致电 WCF 服务

路由应该在哪里?

1 个答案:

答案 0 :(得分:0)

我终于找到并实施了答案。似乎http.sys处理我们需要的一切。只有路由模板应该不同。

initiateApis方法,它使用参数作为uri调用WebAPI和WCF类的Start方法。

在WebAPI课程中 - WebApi.cs

WebApp.Start<WebApi>(uri);

在WCF课程中 - WcfService.cs

_serviceHost = new DataServiceHost(typeof(WcfService), new Uri[0]);
_serviceHost.AddServiceEndpoint(typeof(IRequestHandler), httpBinding, uri);

所以每当传递网址时,

WebApi.Start("http://localhost:17505/api/v4/");
WcfService.Start("http://localhost:17505/api/v3/");

快乐编码:)