UriTemplateTable does not distinguish verbs

I am trying to create a REST service in .NET 3.5 with WCF REST Contrib . My service is almost working fine, but I ran into a bizarre error.

Basically, I have two methods:

[WebInvoke(UriTemplate = "/books?id={identity}", Method = "PUT")]
public string InsertBook(string identity, Book book)
{
 // snipped
}

      

and

[WebInvoke(UriTemplate = "/books?id={identity}", Method = "GET")]
public Books[] ListBooks(string identity)
{
 // snipped
}

      

However, I get an error during activation:

System.InvalidOperationException was not handled by user code Message = "UriTemplateTable does not support multiple templates that have an equivalent path as template / books? Id = {identity} 'but have different query strings where query strings cannot be unambiguously resolved via literal values. See the documentation for UriTemplateTable for details. " Source = "System.ServiceModel.Web"

If I rename the second method as /books2?identity

then it works fine.

Any idea why UriTemplateTable

not distinguish verbs?

+2


a source to share


1 answer


Finally found a solution. In the web.config file, the binding must be specified as webHttpBinding

(instead of the default basicHttpBinding

).



<system.serviceModel>
  <services>
    <service name="Foo.MyService">
      <endpoint address="" binding="webHttpBinding" contract="Foo.MyService" />
    </service>
  </services>
</system.serviceModel>

      

+2


a source







All Articles