2

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"};
    }
Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
mark smith
  • 20,637
  • 47
  • 135
  • 187
  • Are you sure you browsing the correct service class? you said this is your first WCF rest project, is it possible that you have created another service class - other than WcfRestService1. – RocketMan May 14 '12 at 18:15

0 Answers0