Question

I am not able to access any method with the attribute [webinvoke] in a RESTful WCF service.

My code is like this:

[OperationContract]
[WebInvoke(Method = "Post", UriTemplate = "Comosite/{composite}", ResponseFormat = WebMessageFormat.Xml)]
CompositeType GetDataUsingDataContract(string composite);        

On executing the above service I am getting an error message

Method not allowed.

I tried many ways, by modifying the urltemplate, method name and method type etc. but nothing is working out.

But if I use the [WebGet] attribute the the service method is working fine.

Can anybody suggest me what can I do make it work?

Thanks in advance... :)

Was it helpful?

Solution

Try changing

[WebInvoke(Method = "Post", UriTemplate = "Comosite/{composite}", ResponseFormat = WebMessageFormat.Xml)]

to

[WebInvoke(Method = "POST", UriTemplate = "Comosite/{composite}", ResponseFormat = WebMessageFormat.Xml)]

OTHER TIPS

I created a similar service as you have done here and called it with fiddler and that worked when I changed the method to POST all capital letters. When method is like Post as in your code I get an endpoint not found message.

My fiddler request looked like this:

http://localhost/service/service1.svc/Comosite/test 

Here test is sent in as the composite parameter and I get a CompositeType as xml returned.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top