1

Problem Statement: A service that can be accessed by both client-side (jquery) and server-side (asp.net) applications. All the applications are internal apps. Note: Preferrable format of communication is JSON

Description:

I need to expose a persistent store (database) through a service which provides CRUD operations. The service needs to be accessible from both client-side applications via jquery and server-side applications such as asp.net webapplications.

From my initial research, I realized that if I go with asp.net ajax asmx (or) ajax enabled wcf service, I will not be able to use this in other applications due to cross-domain / cross-scripting issues (ref: calling asmx web service from jQuery).

I saw workarounds using JSONP but my understanding is that only get requests are supported and its a hacky either way.

I think I'm all over the place. Here are some of the links I went through :

http://forums.asp.net/p/1512786/3609834.aspx

How to call external webservice using jquery "jsonp"?

can jquery ajax call external webservice?

What is the best way to call a .net webservice using jquery?

What are some good examples of JQuery using JSONP talking to .net?

http://msdn.microsoft.com/en-us/library/cc716898.aspx

http://www.west-wind.com/Weblog/posts/107136.aspx

http://abcoder.com/javascript/jquery/jsonp-first-timer/

Post data to JsonP

http://donatstudios.com/JSONP

https://web.archive.org/web/20211016203116/http://www.4guysfromrolla.com/articles/111710-1.aspx

I'm going towards a self-hosted WCF Restful service that deals with JSON. Is this a viable options ? Any issues with Restful WCF Service ? Any suggestions ?

Note: I'm using C# and .NET 3.5 SP1

Please advise.

Community
  • 1
  • 1
StudentForever
  • 631
  • 2
  • 9
  • 16

1 Answers1

1

If you host a web service, if on the same domain, you may be able to use JQuery to call it. The ScriptManager proxy approach does not work out of the box, but it's possible to do through the Sys.Net.WebServiceProxy class. Otherwise, worst-case scenario is that you create your dedicated service, and have an ASMX or AJAX-enabled WCF service wrap it to provide you the generated proxy features and cross-domain calls.

Nate
  • 30,286
  • 23
  • 113
  • 184
Brian Mains
  • 50,520
  • 35
  • 148
  • 257
  • Thanks. No, it will not be in the same domain. The problem with wrapping the dedicated service calls using ASMX (or) AJAX Enabled WCF service will be this needs to be duplicated everywhere. Multiple applications will be using this service so every application i.e. every application which needs to access it using jquery will have to duplicate code. The challenge is to enble reusability but still keep it flexible. Am I missing anything ? – StudentForever Feb 25 '11 at 01:47
  • No, that's exactly the issue, and I'm afraid that there isn't away around it if on a separate domain. This is a browser restriction (same domain) as a security feature. – Brian Mains Feb 25 '11 at 13:20