2013-08-05 56 views
0

任何想法为什么最后两个URI模板报告没有找到端点?找不到八个WCF REST端点中的两个端点的可能原因?

v1/version 
v1/locations/{id} 
v1/locations/{id}/signals 
v1/locations&q={searchText} 
v1/locations/signals/{signalIds} 
v1/signals/{id} 
v1/locations/{id}/visits 
v1/locations/{locationId}/visits/{id} 

以前所有的6条航线正常工作,但是当我添加的最后2路,他们与404“端点找不到” WCF框架消息做出响应。所有8条路由都是GET方法,我已经使用Fiddler进行了验证,确实使用了GET动词。我看不到与仍在工作的其他REST方法有什么不同。

是成功获取位置ID = 2

GET http://localhost:57004/AppsService.svc/v1/locations/2 

返回这个正确的JSON

测试网址:

{ 
    "Id": 2, 
    "Identifier": "L85", 
    "Name": "The Huge Lake", 
    "Signals": null 
} 

下面是测试URL从试图从位置ID的所有 “访问” 对象= 2

GET http://localhost:57004/AppsService.svc/v1/locations/2/visits 

该URL因404框架异常而失败:

<HTML> 
    <HEAD> 
     <STYLE type="text/css">#content{ FONT-SIZE: 0.7em; PADDING-BOTTOM: 2em; MARGIN-LEFT: 30px}BODY{MARGIN-TOP: 0px; MARGIN-LEFT: 0px; COLOR: #000000; FONT-FAMILY: Verdana; BACKGROUND-COLOR: white}P{MARGIN-TOP: 0px; MARGIN-BOTTOM: 12px; COLOR: #000000; FONT-FAMILY: Verdana}PRE{BORDER-RIGHT: #f0f0e0 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #f0f0e0 1px solid; MARGIN-TOP: -5px; PADDING-LEFT: 5px; FONT-SIZE: 1.2em; PADDING-BOTTOM: 5px; BORDER-LEFT: #f0f0e0 1px solid; PADDING-TOP: 5px; BORDER-BOTTOM: #f0f0e0 1px solid; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e5e5cc}.heading1{MARGIN-TOP: 0px; PADDING-LEFT: 15px; FONT-WEIGHT: normal; FONT-SIZE: 26px; MARGIN-BOTTOM: 0px; PADDING-BOTTOM: 3px; MARGIN-LEFT: -30px; WIDTH: 100%; COLOR: #ffffff; PADDING-TOP: 10px; FONT-FAMILY: Tahoma; BACKGROUND-COLOR: #003366}.intro{MARGIN-LEFT: -15px}</STYLE> 
     <TITLE>Service</TITLE> 
    </HEAD> 
    <BODY> 
     <DIV id="content"> 
      <P class="heading1">Service</P> 
      <BR/> 
      <P class="intro">Endpoint not found.</P> 
     </DIV> 
    </BODY> 
</HTML> 

以下是完整的服务接口代码:

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Runtime.Serialization; 
using System.ServiceModel; 
using System.ServiceModel.Web; 
using System.Text; 
using WebAppsService.Models; 

namespace WebAppsService 
{ 
    [ServiceContract] 
    public interface IAppsService 
    { 
     [OperationContract] 
     [WebGet(RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, 
      UriTemplate = "v1/version")] 
     string GetVersion(); 

     [OperationContract] 
     [WebGet(RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, 
      UriTemplate = "v1/locations/{id}")] 
     Location GetLocation(string id); 

     // DCSR-specific Location APIs 
     [OperationContract] 
     [WebGet(RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, 
      UriTemplate = "v1/locations/{id}/signals")] 
     List<Signal> GetLocationSignals(string id); 

     [OperationContract] 
     [WebGet(RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, 
      UriTemplate = "v1/locations&q={searchText}")] 
     List<Location> GetLocations(string searchText); 

     [OperationContract] 
     [WebGet(RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, 
      UriTemplate = "v1/locations/signals/{signalIds}")] 
     List<Location> GetLocationsContainingSignals(string signalIds); 

     [OperationContract] 
     [WebGet(RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, 
      UriTemplate = "v1/locations/{id}/visits")] 
     List<Visit> GetVisits(string id); 

     [OperationContract] 
     [WebGet(RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, 
      UriTemplate = "v1/locations/{locationId}/visits/{id}")] 
     Visit GetVisit(string locationId, string id); 

     [OperationContract] 
     [WebGet(RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, 
      UriTemplate = "v1/signals/{id}")] 
     Signal GetSignal(string id); 
    } 
} 

任何想法?

回答

0

发现问题:我。

在我调试过端点#6后,我将项目的OutputPath属性从默认的“bin”更改为“$(SolutionDir)\ $ Configuration)”,这是我们用于我们所有项目的模式。

事实证明,当您从VS调试Web项目时,它总是通过IIS或Cassini独立Web服务器启动项目时,在程序集的相关“bin \”文件夹中查找。该项目的OutputPath属性被忽略而没有投诉。

所以我留下了调试我的程序集的旧版本,只包含前6个端点的路线。 sheesh