tags:

views:

20

answers:

1

I am working on a WCF REST service, and in the service I have two methods with the same URITemplate. One of them is marked with a WebGet and the other with a WebInvoke using PUT as the method.

[WebGet(URITemplate="{name}")]
public Something GetSomethingNamed(string name)


[WebInvoke(Method="PUT", URITemplate="{name}")]
public Something AddSomethingNamed(Something somethingToAdd)

When trying to test something in the service, best way to handle an exception, by attempting to browse to the GET method in IE I received an error that AddsomethingNamed required a parameter named NAME.

I am slightly baffled by this response as I don't even know how it was getting to the PUT method, from what I know web browsers don't even directly support PUT.

+1  A: 
[WebInvoke(Method="PUT", URITemplate="{name}")] 
public Something AddSomethingNamed(Something somethingToAdd) 

In your above code in the URI template you mentioned {name} which means that your method accepts one more parameter "name".

So your method signature should be either of the following

[WebInvoke(Method="PUT", URITemplate="AddSomethingNamed")] 
public Something AddSomethingNamed(Something somethingToAdd) 

OR

[WebInvoke(Method="PUT", URITemplate="{name}")] 
public Something AddSomethingNamed(string name, Something somethingToAdd)
lucene user