views:

15

answers:

0

Hi there,

Been writing my first WCF Rest service and its going well... but i have a small issue, can anyone help?

When i goto my help page which on local pc is like so

  http://localhost/WcfRestService1/help

It displays the following, but the URI is wrong, notice the URI is blank or only asks for the parameter {id}

Uri     Method      Description
            GET     Service at http://localhost/WcfRestService1/
            POST    Service at http://localhost/WcfRestService1/
{id}        GET     Service at http://localhost/WcfRestService1/{ID}
            PUT     Service at http://localhost/WcfRestService1/{ID}
            DELETE  Service at http://localhost/WcfRestService1/{ID}

It really should be (see below for my methods)

  Uri

  Tasks  Get .... 
  Users/{id}    Get ....

Here are my methods so surley the URI should show the correct URI, see my attribute UriTemplate

    [WebGet(UriTemplate = "Tasks")]
    public List<SampleItem> GetCollection()
    {
        // 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 Get(string id)
    {
        // TODO: Return the instance of SampleItem with the given id
        //throw new NotImplementedException();
        return new SampleItem() {Id = 1, StringValue = "Hello"};
    }