我正在开展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 服务
路由应该在哪里?
答案 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/");
快乐编码:)