Sudheer Kaju
Sudheer Kaju

Reputation: 275

Calling Wcf service from jquery

I have no knowledge on WCF services. I am from java background. I need to use a WCF service i.e. http://192.168.1.5/xeservices/AccountManagement.svc with jquery and ajax. I don't know how to use it. I have no .net in my system also. From service I found that I should have svcutils.exe in ordered to create client. I know, by installing Microsoft SDK I can get it. Please anybody tell me how to achieve my goal.

Upvotes: 2

Views: 744

Answers (3)

Sagar Hirapara
Sagar Hirapara

Reputation: 1697

Try this

For Json Type result

In InterFace

[WebInvoke(Method = "POST", UriTemplate = "/ItemGetItem?id={id}", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
[OperationContract]
void  ItemGetItem(string id);

In Script

self.GetItem= function () {
         try {
             $.ajax({
                 type: "POST",
                 url: "Your Url",
                 contentType: 'application/json',
                 async: false,
                 dataType: 'json',
                 cache: false,
                 success: function (response) {
                      //Do some stuff here with Data
                 },
                 error: function (ErrorResponse) {
                      //Handle error
                 }
            });
         }
         catch (error) {

         }
     }

put endpoint of client application to consume this service

Upvotes: 1

Sreekumar P
Sreekumar P

Reputation: 6050

If your WCF Service is written in such a way, like in the CodeProject links in the comments, you can access a WCF Service like javascript snippet show in that.

http://www.codeproject.com/Articles/132809/Calling-WCF-Services-using-jQuery

Upvotes: 1

Amit
Amit

Reputation: 15387

No need to install .Net or its framework, direct use WCF URL using AJAX and Jquery.

Upvotes: 2

Related Questions