* IBM to offer mobile security as a service IBM will start delivering mobile security-as-a-service (MaaS) through its own cloud infrastructure in India, a move that is expected to better address in-country data requirements... IBM Spectrum Computing: IBM has enlarged its portfolio of software-defined infrastructure solutions with cognitive features for workload management.  * LiFi internet technology has been introduced, the new type of wireless internet connection that gives 100 times faster than traditional WiFi -- Invented by Professor Harald Haas from the University of Edinburgh. * Sci. Rachid Yazami has developed a smart chip that charges smartphones in less than 10 minutes. BenQ has launched BlueCore projector - Consumer electronics major BenQ has launched its first BlueCore laser light source projector. For those unaware, devices with BlueCore laser technology have a high contrast output of 80000:1 with an extended lamp life and efficiency. *** 
  Mar 27 2016 1:04PM     John
  0 Comments    3128 Views  
In this article John demonstrates, how to call a simple WCF Service from jQuery in C#. The following is the procedure.
Create Service Contract
1. Launch any edition of Visual Studio 2010 or 2012.

2. Create a project by choosing WCF Service Application project template from WCF tab.

3. Let us give the WCF Service Name "MySampleWCFService".

4. Ensure the attribute of the Interface is set as "[ServiceContract]".

5. Define the functions you want to create as part of the Contract Set the Attribute of the functions as "[OperationContract]"
You will create an IService1 Service Contract with the four basic calculator operations as the following.
namespace WcfService1
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
    public interface IService1
        [WebInvoke(Method = "GET", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)]
        string GetData(int value);

        [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)]
        string[] GetUser(string Id);

    // Use a data contract as illustrated in the sample below to add composite types to service operations.
    public class CompositeType
        bool boolValue = true;
        string stringValue = "Hello ";

        public bool BoolValue
            get { return boolValue; }
            set { boolValue = value; }

        public string StringValue
            get { return stringValue; }
            set { stringValue = value; }
You have created a Service Contract. These contracts will be part of the Service Contract and exposed to clients. By this step you have created the IService Service Contract.
Implement the Service
Replace the getdata function with the following code.
namespace WcfService1

    = AspNetCompatibilityRequirementsMode.Allowed)]
    public class Service1 : IService1
        public string GetData(int Id)
            return string.Format("You entered: {0}", Id);

        public string[] GetUser(string Id)
            return new User().GetDetails(Convert.ToInt32(Id));

    public class User

        Dictionary<intstring> users = null;
        public User()
            users = new Dictionary<intstring>();
            users.Add(1, "The");
            users.Add(2, "Developer");
            users.Add(3, "Tips");
            users.Add(4, "Beyond The knowledge");

        public string[] GetDetails(int Id)
            var user = from u in users
                       where u.Key == Id
                       select u.Value;

            return user.ToArray<string>();

Now you need add a new page Default.aspx and add the below code in the Javascript.
<script src=""></script>

    <script type="text/javascript">

        $(document).ready(function () {
            type: "POST",
            url: "Service1.svc/GetUser",
            data: {"Id": 1},
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            processdata: true,
            success: function (msg) {

                if (msg == "json") {
                    var resultObject = msg.GetUserResult;

                    for (i = 0; i < resultObject.length; i++) {

            error: function (result) {
                alert('Service call failed: ' + result.status + '' + result.statusText);
To call WCF Service, press F5 in Visual Studio and WCF Service will be calling in Java Script page load.
I hope this page will helps you to call WCF service from jQuery in C#.Thanks.

Recent Posts
Create Amazon ElasticCache Using Memcached in CSharp
Oct 29 2018 12:09PM Posted By Amose
Get Google Map Lat Lng (Geo Point) By Pincode in C#
Oct 28 2018 12:09PM Posted By Pranav
Google URL Shortener in C#
Oct 20 2018 12:09PM Posted By Sanjay
Bind Gridview from CSV file in Asp.Net C#
Oct 5 2018 12:09PM Posted By Michael
Call WebService method from jQuery in every 1 minute
Sep 26 2018 12:09PM Posted By John
Gridview custom CSS in ASP.Net
Sep 14 2018 12:09PM Posted By Micheal Ryan
Read excel file and bind to Gridview in C#
Sep 10 2018 12:09PM Posted By Micheal
Follow us on Facebook
Follow us on Google +
Recent post in your Email inbox.
Enter your email address: