我有三條定義的路線。前兩個工作正常,但最後一個返回主題中的錯誤。ServiceStack:找不到請求的處理程序?
Routes.Add<FeeInstructionsList>("/policies/{clientPolicyId}/feeinstructions", "GET");
Routes.Add<FeeInstructionsEdit>("/policies/{clientPolicyId}/feeinstructions/{feetype}", "GET");
Routes.Add<List<FeeInstructionEditInfo>>("/policies{clientPolicyId}/feeinstructions", "POST");
當我有第三條道路爲只是「/ feeinstructions」,它工作得很好,但是當我添加的路由如上這是行不通的。
FeeInstructionEditInfo沒有名爲「clientPolicyId」的memeber。這可能是一個原因。如果是這樣,我如何將它傳遞到服務而不需要修改我的dto。它是否可以成爲像這樣的服務操作的附加參數。我不這樣做是可能的,因爲ss是每個請求一個dto,但也許有一種方法?
public List<FeeInstructionEditInfo> Post(int clientPolicyId, List<FeeInstructionEditInfo> request)
目前,這個方法聲明爲
public List<FeeInstructionEditInfo> Post(List<FeeInstructionEditInfo> request)
這是請求被髮送
> POST http://localhost:12543/api/policies/680455600/feeinstructions/
> HTTP/1.1 Content-Type: application/json Accept-Language: en-US
> Referer: http://localhost:12543/ClientBin/SR.SRUnite.ShellUI.xap
> Content-Length: 1408 Accept-Encoding: identity Accept:
> application/json User-Agent: Mozilla/5.0 (compatible; MSIE 9.0;
> Windows NT 6.1; WOW64; Trident/5.0; BOIE9;ENUS) Host: localhost:12543
> Connection: Keep-Alive Pragma: no-cache
這是我原來的DTOS,而這些都沒有改變
[Route("/policies/{clientPolicyId}/feeinstructions/{feetype}","GET")]
public class FeeInstructionsEdit
{
public int ClientPolicyId { get; set; }
public string FeeType { get; set; }
}
public class FeeInstructionsEditResponse
{
public List<KeyValuePair> Instructions { get; set; }
public List<KeyValuePair> Contacts { get; set; }
public List<FeeInstructionEditInfo> FeeInstructions { get; set; }
}
public partial class FeeInstructionEditInfo
{
public int FeeInstructionId { get; set; }
public string FeeTypeCode { get; set; }
public string FeeTypeDescription { get; set; }
public string FeeTypeGroupCode { get; set; }
public string ProductName { get; set; }
public string InsuredType { get; set; }
public string Demographic { get; set; }
public string Instruction { get; set; }
public string Contact { get; set; }
public decimal? FeeAmount { get; set; }
}
我是ld將FeeInstructionEditInfo的列表發佈到/ clientPolicies/342434/feeinstructions,它不起作用,但發佈到/ feeinstructions會。
我現在發佈使用這對dto的。
[Route("feeinstructions","POST")]
public class FeeInstructionsSave
{
public int ClientPolicyId { get; set; }
public List<FeeInstructionEditInfo> FeeInstructions { get; set; }
}
public class FeeInstructionsSaveResponse : IHasResponseStatus
{
public ResponseStatus ResponseStatus { get; set; }
}
'[路線( 「feeinstructions」, 「POST」)]'應該有一個'/'前綴例如'/ feeinstructions'。這應該是[ServiceStack的最新版本]中的啓動錯誤(https://plus.google.com/u/0/106787359118990653189/posts/gVn3cccmMHt)。 – mythz 2013-04-08 18:23:09