Clarification needed about WCF Concurrency in REST Services -


i have created wcf rest services. when hitting same request continuously client(i.e android mobile) using diifrerent threads , thread.sleep not working.

my code below this..

[servicebehavior(instancecontextmode = instancecontextmode.percall, concurrencymode = concurrencymode.single)]     public class service1 : iservice1     {       [webinvoke(method = "post", requestformat = webmessageformat.json, responseformat = webmessageformat.json, bodystyle = webmessagebodystyle.bare, uritemplate = "verifylogin")]         public bool verifylogin(login logincred)         {             bool res = false;             string strthreadprint= "";             try             {                strthreadprint= thread.currentthread.managedthreadid.tostring() + "  time @ : "+datetime.now;                thread.sleep(5000);                 dbcon = new dbconnection(); //for testing here throwing exception going catch block , responce sent client exception details shown in catch block.                dbcon.verifylogin(logincred.username.trim(), logincred.password.trim());              }             catch (exception sqlex)             {                 objerrorclass = new errorclass("login class", sqlex.message + " --- " + strthreadprint, "cnmk");                 throw new webfaultexception<errorclass>(objerrorclass, system.net.httpstatuscode.badrequest);              }         }     } 

when sending request using fiddler following requestbody {"username":"13","password":"dgdf"}

at time getting responce in json format

response service:  {"errordesc":"login failed --- 33 time @ :09/04/2013 12:31:30"} {"errordesc":"login failed --- 35 time @ :09/04/2013 12:31:30"} {"errordesc":"login failed --- 41 time @ :09/04/2013 12:31:30"} {"errordesc":"login failed --- 45 time @ :09/04/2013 12:31:30"} 

so instance mode , concurrency mode not working wcf restful services???? or doing wrong in code?? please me

if understand correctly want have wcf host single instance of service operation , have service wait 5 seconds before responding?

if should use instancecontextmode.single, mean service requests routed same instance of service processing.

edit

i don't understand behavior want see. have 4 concurrent requests, have per call service instance, have 4 requests processed @ same time 4 different service instances. cannot see problem output.

edit2

concurrencymode determine how each instance of service deals concurrent requests dispatched instance.

however, specifying instance per call. have 4 calls, therefore have 4 instances of service net result each call processed concurrently.

so behavior observing correct way have configured service.

if want single service instance process calls need specify instancecontextmode.single.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -