1
我想知道是否有人可以確認我使用的命名約定是正確的,我剛剛開始,真的不想陷入壞習慣WCF休息方法和URI的命名約定?
這是我擁有的...(查看評論)
基本上我有一個名爲GetTasks的方法,但uri是任務 - 我認爲這是要走的路?
另外我有一個名爲的getUser方法,其中URI是(複數)用戶/ {ID}
任何確認之前,我仍然將是巨大的..謝謝..
這裏有我有方法目前..
[WebGet(UriTemplate = "Tasks")]
public List<SampleItem> GetTasks() //RETURNS a COLLECTION
{
// TODO: Replace the current implementation to return a collection of SampleItem instances
return new List<SampleItem>() { new SampleItem() { Id = 1, StringValue = "Hello" } };
}
[WebGet(UriTemplate = "Users/{id}")]
public SampleItem GetUser(string id) // RETURNS A USER
{
// TODO: Return the instance of SampleItem with the given id
//throw new NotImplementedException();
return new SampleItem() {Id = 1, StringValue = "Hello"};
}
[WebInvoke(UriTemplate = "Users/{id}", Method = "PUT")]
public SampleItem UpdateUser(string id, SampleItem instance) // UPDATES A USER
{
// TODO: Update the given instance of SampleItem in the collection
throw new NotImplementedException();
}
[WebInvoke(UriTemplate = "Users/{id}", Method = "DELETE")]
public void DeleteUser(string id) // DELETES A USER
{
// TODO: Remove the instance of SampleItem with the given id from the collection
throw new NotImplementedException();
}
有一件事我是littel困惑的是「GetUser」Uri是(複數)用戶/ {id}或應該是(單數)User/{id} – 2010-08-07 15:44:19