Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 672687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:30:43+00:00 2026-05-14T00:30:43+00:00

I have a WCF Service (called myservice.svc) that takes a message from a user

  • 0

I have a WCF Service (called “myservice.svc”) that takes a message from a user and saves it to the database. It returns a response to the user in the form of a number. This operation looks like this:

[OperationContract]
[WebGet]
public string SubmitMessage(string message)
{
  try
  {
    // SAVE TO DATABASE
    return "1";
  }
  catch (Exception ex)
  {
    return "0";
  }
}

I want to call this operation from some JQuery. I’m using the approach shown here:

$.getJSON(
  "/services/myService.svc",
  {message:"some text"},
  function (data) {
    alert("success");                
  }
);

Oddly, the “success” alert is never displayed. In addition, I have set a breakpoint in my WCF service and it is never being tripped. What am I doing wrong?

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T00:30:43+00:00Added an answer on May 14, 2026 at 12:30 am

    That WebGet shouldn’t be there, and you shouldn’t be using the jQuery getJSON function. This method modifies the database; it is a POST method, not GET.

    See this page for an example of creating a POST method. Mainly it involves adding these headers to the method:

    [OperationContract]          
    [WebInvoke(Method = "POST",
               BodyStyle = WebMessageBodyStyle.Wrapped,
               RequestFormat = WebMessageFormat.Json,
               ResponseFormat = WebMessageFormat.Json)]
    

    You also need to make sure that you make the call correctly from jQuery, which includes setting the contentType and other fields; the way you’re making the call actually isn’t valid, you’re just passing raw text to the method, not a valid query string or valid JSON.

    Also, you’re using the wrong URL; you don’t want to be posting to the endpoint, you need to post to the specific method, you have to append that to the URL. Again, the linked page should help explain all of this.

    Here’s an example of a correct jQuery Ajax post:

    $.ajax({ 
        url: "/services/myservice.svc/SubmitMessage",
        type: "POST",
        contentType: "application/json; charset=utf-8",
        data: "{ \"message\": \"test\" }",
        dataType: "json",
        success: function(data) {
            // do something
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WCF service (MyService.svc) that im hosting under IIS 7.5. My .svc
I have a WCF service that gets called from a client. When there is
I have Silverlight application that retrieves data from the database through a WCF Service.
I have a WCF service that I have to reference from a .net 2.0
I have a WCF service, hosted in IIS 7.0 that needs to run database
I have a simple WCF service that I call server side from code behind
I have a WCF service that does some document conversions and returns the document
I have a WCF Data Service that exposes an Entity Framework database context and
I have a WCF web service called Palladium that is created as a project
I have a WCF service that is called by a Windows Mobile application running

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.