Click here to Skip to main content
Click here to Skip to main content

Tagged as

RESTful API in WCF get called more than one time, but client called it once only!! What is wrong? Your answer is here!!

, 1 Mar 2012
Rate this:
Please Sign up or sign in to vote.
Have you ever came across such situation where you have a RESTful WCF service which has some WebGet or WebInvoke OpertationContract in your ServiceContract. And when you calling one of WebGet API using RESTful URL or from client side application, that API get called twice or thrice at server level. Means your API get execute twice or thrice but your client had called it only once.
 
I had faced above few with in a yr, but did not able to find out why it was happening, and some how it got fix/working normally. I had done lots many reach on it, like why its happening and how it happening. Enabled all levels of tracing. And found some interesting.
 
1. I able to prove with my logs that client is only making 1 call to API
2. RESTful WCF service at get executed twice or thrice
3. There are twice or thrice IIS log at server level of that API
 
I had search google many time but able to get any proper answer for it. But lastly this time, I found perfect solution on it by reading a article from a site Lear REST[^]
In that site there was a very strong point was mention which was very basic but that give me reason to think.
 
GET requests should be for read-only queries; they should not change the state of the server and its data.

 
Above point make me to think, that do I really doing same with my WebGet API? and my answer was No!!
I was doing some manipulation/object creation/correct of data before getting data in that WebGet (Http GET) API. Then I, change that API to WebInvoke (Http POST) and it worked!! only 1 call received at server and it was process normally and successfully.
 
Then I started figure out why it was happening such for Http GET. and something which i found is that IIS has some setting for HTTP GET as 40sec replay, so if within 40sec if server does not get response it again query itself. I am not sure how much I am correct here. But my fix worked...
 
Hope this article is use full for those who are also facing such issue and doing google but did not finding any result or solution. But there answer is here 1st on net.
 
Thank
Sumit

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

SumitJaiswal
Software Developer (Senior) Tata Consultancy Services
India India
MCTS in Windows Workflow foundation 3.5

Comments and Discussions

 
QuestionPlease explain more about your fix. I have same problem. i could not fix.. Pinmembermahadevan0121-Aug-14 20:51 
GeneralMy vote of 5 Pinmembersriharikilari124-Jan-13 20:10 
GeneralRe: My vote of 5 Pinmembermahadevan0121-Aug-14 20:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web01 | 2.8.140827.1 | Last Updated 1 Mar 2012
Article Copyright 2012 by SumitJaiswal
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid