OData and custom WCF WebGet methods

Posted by reinier on Stack Overflow See other posts from Stack Overflow or by reinier
Published on 2010-05-31T08:10:07Z Indexed on 2010/05/31 8:12 UTC
Read the original article Hit count: 728

Filed under:
|
|
|
|

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.

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET