How to Invoke a WCF Service from AJAX

7. May 2007 20:54

A couple of weeks ago, a customer was having trouble using a WCF service from a client-side ASP.NET AJAX script.  Unfortunately for the customer, the current release of ASP.NET AJAX doesn't currently support direct communication with a WCF service.  Direct support for WCF was removed for the official release of ASP.NET AJAX, but it is scheduled to be included within the Orcas release coming late this year.  Fortunately, there is a temporary solution that allows communication between ASP.NET AJAX and WCF.

Rather than directly accessing WCF from a client-side script, an ASMX web service can be used to wrap the WCF service.  The client-side script will communicate with the ASMX web service, and the ASMX web service will forward the request directly to the WCF service.  This does result in some additional overhead.  However, it provides a clean "forward looking" solution that easily enables adoption of direct WCF communication when Orcas is released.  Once the functionality is released, you can simply drop the ASMX wrapper and the client script can directly talk to WCF with minimal effort.

This has likely been covered in other places, but it still seemed like a useful tidbit of information to pass along.

Comments are closed

About Me

I'm a passionate software developer and advocate of the Microsoft .NET platform.  In my opinion, software development is a craft that necessitates a conscious effort to continually improve your skills rather than falling into the trap of complacency.  I was also awarded as a Microsoft MVP in Connected Systems in 2008, 2009, and 2010.

Can’t code withoutThe best C# & VB.NET refactoring plugin for Visual Studio
Follow jeff_barnes on Twitter

View Jeff Barnes's profile on LinkedIn


Shared Items


Anything you read or see on this site is solely based on my own thoughts.  The material on this site does not necessarily reflect the views of my employer or anyone else.  In other words, I don't speak for anyone other than myself.  So, don't assume I am the official spokesperson for anyone.