Reputation: 2158
As mentioned in 2009, WCF could not differentiate the following urls to return a list of Users and a specific User:
/users
/users/{id}
Is this still the case with WCF4?
Upvotes: 1
Views: 2908
Reputation: 4625
David's answer is great, but I'd use:
[OperationContract(Name="Op1")]
[WebGet(UriTemplate = "DoWork/")]
int[] DoWork();
[OperationContract(Name = "Op2")]
[WebGet(UriTemplate = "DoWork/{id}")]
int[] DoWork(string id);
Upvotes: 3
Reputation: 2795
You can do this now:
[OperationContract(Name="Op1")]
[WebInvoke(Method= "GET", UriTemplate = "DoWork/")]
int[] DoWork();
[OperationContract(Name = "Op2")]
[WebInvoke(Method = "GET", UriTemplate = "DoWork/{id}")]
int[] DoWork(string id);
The important thing is that the OperationContract must have the Name= property with different names for each operation.
Upvotes: 1