OData and custom WCF WebGet methods
- by reinier
I've created an OData endpoint (using entity framework, WCF data service)
and added a custom test WebGet test method like so:
[WebGet(UriTemplate = "{text}")]
public IQueryable<string> SplitString(string text)
{
if (text == null) throw new DataServiceException("text not specified");
var result = (from s in text.Split('-') orderby s select s);
return result.AsQueryable();
}
and a config line:
config.SetServiceOperationAccessRule("SplitString", ServiceOperationRights.All);
However, no matter how I specify the url, I can not get the text param to be filled out. (it is always null).
so:
http://localhost/myservice.svc/SplitString/testtext
does not work.
What is the correct url format (or UriTemplate) one should use?
The only examples I found of odata and WebGet only have an example method which doesn't have any parameters.