c# - How to force a synchronous call to a web service -


public string createorder(string purchaseorder) {     using (mywebservice.createservice service = new mywebservice.createservice())     {         string ordercode = service.createorder(purchaseorder);          return ordercode;     } } 

i've added web service reference domain layer of asp.net web app.

this generates 2 methods expected - createorder , createorderasync.

using thought should synchronous call above though, still seems calling asynchronously. above code returns null every time, though web service runs correctly.

if add thread.sleep before return statement, correct value back.

how can force synchronous call? , why calling async anyway since that's not function i'm using?

note return value has returned client through ajax call, can't see anyway achieve using callback web service.

edit: bit more specific because not problem client code.

the above method called controller so:

string ordercode;  try {     ordercode = orderservice.createorder(purchaseorder);      // if uncomment below line, order code , works ok.     // otherwise exception thrown every time.     // system.threading.thread.sleep(10 * 1000);      if (ordercode == null)     {         throw new dataexception("failed allocate ordercode new order");     }      // ... etc } 


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -