AJAX enabled WCF service in MVC? - ajax

So I can create a simple AJAX enabled WCF Service and consume it in Javascript in a basic WebForm as found in this example on MSDN (http://msdn.microsoft.com/en-us/library/bb924552.aspx).
Is it possible though to do this in ASP.NET MVC 3/4? The problem is there is no ScriptManager control obviously, which allows me to reference the service to be used in the javascript.
If it's not possible - how do I consume a WCF service inside javascript from ASP.NET MVC?
I cannot find any examples of this online either.. My google fu is off and I can't figure out what I'm missing here.
thanks!

Make sure that your WCF service works with JSON and then use JQuery to call the service. This might help: http://pranayamr.blogspot.com/2010/12/steps-to-call-wcf-service-using-jquery.html

Related

How can I implement frontend in API without using a framework?

hope you are having a great day.
I will get straight to the point, I have an application in Spring. I am using API calls from postman to retrieve my data.
Now I am asked to implement a front-end but without a framework, I was told that only ajax and javascript should do the trick.
How would I be able to implement this?
Keep in mind it is not an MVC application, but rather an API.
Thanks in advance
Several ways of doing so ! You can use
Javascript
Jquery
Angular JS
Check if below article helps
How to call a REST web service API from JavaScript?

Using own domain model/entity on client with wcf data service (uses web api/odata/entity framework) as service reference

Here's my situation, I'm trying to create a WPF application that connects to my own web odata service (uses web api and entity framework). I have my own set of domain models/entities in the server side that the web api and entity framework works with. When, I add the web odata service reference in the WPF client side, it can't recognize my own domain models/entities and it looks like it creates its own set of it. Is what I'm trying to do even possible or am I just missing something?
Regards,
Raymond
Drive-by answer (unchecked): I remember reading that it wasn't possible at least a few weeks back. You might want to search the Uservoice site and the official forums for current status, or wait for a better answer here.
It looks like this problem is currently a feature suggestion for WCF Data Services (thanks to tne's uservoice link). The direct link to the request is https://data.uservoice.com/forums/72027-wcf-data-services-feature-suggestions/suggestions/3220086-allow-re-using-entities-from-another-dll-on-the-cl.

MVC App Ajax call Controller or WCF

Hi I have worked for a couple companies now. Both used MVC to create their software. One company used WCF Services for all of their Ajax Calls while my most recent company is making all of their Ajax calls to their Controllers. I prefer the WCF method as it seems to keep the code cleaner and more readable, however, according to MVC all view calls should go through a controller. I was just wondering if anyone had any good information, references, or articles as to which is better practice, or if it's better to make service calls to a controller or WCF service? Thanks
It looks both approaches will work fine. But, WCF is more appropriate solution if you want to have something like Service Layer inside of your solution. But for Ajax calls from the Web part to Controller work okay.

Is it possible to use WCF service instead of .asmx web service with AJAX Control Toolkit Slideshow extender?

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.
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
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.
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

Designing a web service to be used by the iPhone and a web client

I'm designing a web service that serves up JSON through a REST API. This API is currently being used by an iPhone app to do CRUD operations.
My question is, can I design a web client that uses this REST API using nothing more than ExtJS (or some other RIA framework) and HTML pages? In other words, can I create a static HTML page that uses ExtJS to send AJAX calls to the REST API and receive JSON data from it? Or is this thinking too naive and wrong?
I think this is perfectly acceptable as long as you know that your users browser will be able to handle javascript and AJAX accordingly.
Yes! YES! You can use static html and js files, served by any web server, to build an Ext JS application. Ext JS is very happy to talk REST and JSON to your web service.
Build your Ext JS application outside of ASP.NET MVC. You don't need it.

Resources