Method Not Allowed(WCF)

Posted: December 5, 2010 in Categories, WCF
Tags: , , , ,

A busy morning & I am late for my office.At times when u really want to reach office on time,something comes in mid & you get delayed.Well I am just in a hurry to do some checkin to vsts as i have my daily test build scheduled in the mornings.

Well,most of my code with stored procs,business layer & data acess is done and only thing pending is just to add the signature to interface & decorate that with a webinvoke attribute as it’s part of an insertion/updation scenario.A simple thing only,still checkin on time is very important otherwise i cannot test it today & wait for another day to do so.

Reached office,opened up my solution ,added the code like this.

[WebInvoke(Method = “put”, UriTemplate = “ProdData”, BodyStyle = WebMessageBodyStyle.Wrapped)]
[OperationContract]
bool PutProductDetailsData(ProductDataDTO prodData);

done! everything set for the checkin.Compiles also beautifully..I dont know why, when i write something & it gives a build succeeded message,i feel quite happy 🙂 Just a thought before checkin..why not test this once locally..i clicked on the respective svc & clicked view in browser..To my surprise it gave me the yellow error page which says Method Not Allowed..strange..i was confused..did i do anything wrong..i thought of comparing the same with the method written next to it..hurried to code file..i dont see any difference at all..what to do next..yesss google comes to my rescue in these situations..got to see a similar issue and figured out what went wrong 🙂 I have written Method=”put” & it’s supposed to be in caps PUT ..it seems Method type is case sensitive 🙂 So the right way to decorate the method is like this.

[WebInvoke(Method = “PUT”, UriTemplate = “ProdData”, BodyStyle = WebMessageBodyStyle.Wrapped)]
[OperationContract]
bool PutProductDetailsData(ProductDataDTO prodData);

Some times mistakes might be too silly but will take minimum an hour to figure out what went wrong..Hope you enjoyed the post & will always remember about the case sensitive nature of method types 🙂

Advertisements
Comments
  1. Joy says:

    Nice..All the best…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s