Click here to Skip to main content
15,607,804 members
Articles / Programming Languages / C#
Posted 1 Mar 2012

Tagged as


5 bookmarked

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

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
1 Mar 2012CPOL2 min read
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.



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

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

Comments and Discussions

Questionproblem with post request Pin
Hossein Ganjyar6-Jul-18 3:57
Hossein Ganjyar6-Jul-18 3:57 
I have this problem with post http request. why?
my class function await for an I/O process for about 1 min. I see after done function process, excute return line but no returned value and class function call twice itself.
QuestionPlease explain more about your fix. I have same problem. i could not fix.. Pin
mahadevan0121-Aug-14 20:51
mahadevan0121-Aug-14 20:51 
GeneralMy vote of 5 Pin
sriharikilari124-Jan-13 20:10
sriharikilari124-Jan-13 20:10 
GeneralRe: My vote of 5 Pin
mahadevan0121-Aug-14 20:52
mahadevan0121-Aug-14 20:52 

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

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