Is it possible to use WCF service instead of .asmx

2019-08-10 11:20发布

问题:

I have a working WCF service that I can call via AJAX javascript routine. I cannot get it to work with the Slideshow extender in the Ajax Control Toolkit. No errors reported, slideshow just does not load and run. I can write AJAX javascript routine within the page and successfully access the return results from the WCF service (array of images). I can use the Slideshow extender without problem using an .asmx web service, but would prefer to use a WCF service if possible.

回答1:

I'm not sure about the concrete example here (Ajax Control Toolkit Slideshow extender), but in general, yes, you can access WCF services from Ajax - see here:

  • Access an AJAX enabled WCF Service
  • JSON-enabled WCF Services in ASP.NET
  • Ajax Autocomplete Extender with WCF

Hope this helps a a bit!

Marc



回答2:

I think this is a bug in the SlideShowExtender.

I have gotten it to work with a PageMethod and an asmx web service but cannot get to work with wcf service.

If I create a AJAX enable WCF service, register it with ScriptManager and call it myself via the auto-generated proxy, I successfully get back the JSON data with the array of slides that I returned from the WCF service.



回答3:

As Marc mentioned, you can use a WCF service with Ajax. The links he cites are good, but there is also an "Ajax Enabled WCF Service" option available when you add a new item in VS 2008 or 2010.

You can also use Dependency-Injection with Spring.Net on a WCF Service that responds to Microsoft Ajax calls. The directions to do so are located on my blog here: http://emilsblog.lerch.org/2010/02/springnet-enabled-wcf-services.html