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 9013901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:22:57+00:00 2026-06-16T03:22:57+00:00

I am a beginner at RESTful services. I need to create an interface where

  • 0

I am a beginner at RESTful services.

I need to create an interface where the client needs to pass up to 9 parameters.

I would prefer to pass the parameters as a JSON object.

For instance if my JSON is:

'{
    "age":100,
    "name":"foo",
    "messages":["msg 1","msg 2","msg 3"],
    "favoriteColor" : "blue",
    "petName" : "Godzilla",
    "IQ" : "QuiteLow"
}'

And if I need to execute a server side method below in the end:

public Person FindPerson(Peron lookUpPerson)
{
Person found = null;
// Implementation that finds the Person and sets 'found'
return found;
}

Question(s):
How should I make the call from the client-side with the above JSON string?
And how can I create a signature and implementation of the RESTful service method that

  • accepts this JSON,
  • parses and deserializes it into Person object and
  • calls / returns the FindPerson method’s return value back to client?
  • 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-06-16T03:22:58+00:00Added an answer on June 16, 2026 at 3:22 am

    If you want to create a WCF operation to receive that JSON input, you’ll need to define a data contract which maps to that input. There are a few tools which do that automatically, including one which I wrote a while back at http://jsontodatacontract.azurewebsites.net/ (more details on how this tool was written at this blog post). The tool generated this class, which you can use:

    // Type created for JSON at <<root>>
    [System.Runtime.Serialization.DataContractAttribute()]
    public partial class Person
    {
    
        [System.Runtime.Serialization.DataMemberAttribute()]
        public int age;
    
        [System.Runtime.Serialization.DataMemberAttribute()]
        public string name;
    
        [System.Runtime.Serialization.DataMemberAttribute()]
        public string[] messages;
    
        [System.Runtime.Serialization.DataMemberAttribute()]
        public string favoriteColor;
    
        [System.Runtime.Serialization.DataMemberAttribute()]
        public string petName;
    
        [System.Runtime.Serialization.DataMemberAttribute()]
        public string IQ;
    }
    

    Next, you need to define an operation contract to receive that. Since the JSON needs to go in the body of the request, the most natural HTTP method to use is POST, so you can define the operation as below: the method being “POST” and the style being “Bare” (which means that your JSON maps directly to the parameter). Notice that you can even omit the Method and BodyStyle properties, since "POST" and WebMessageBodyStyle.Bare are their default values, respectively).

    [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Bare)]
    public Person FindPerson(Peron lookUpPerson)
    {
        Person found = null;
        // Implementation that finds the Person and sets 'found'
        return found;
    }
    

    Now, at the method you have the input mapped to lookupPerson. How you will implement the logic of your method is up to you.

    Update after comment

    One example of calling the service using JavaScript (via jQuery) can be found below.

    var input = '{
        "age":100,
        "name":"foo",
        "messages":["msg 1","msg 2","msg 3"],
        "favoriteColor" : "blue",
        "petName" : "Godzilla",
        "IQ" : "QuiteLow"
    }';
    var endpointAddress = "http://your.server.com/app/service.svc";
    var url = endpointAddress + "/FindPerson";
    $.ajax({
        type: 'POST',
        url: url,
        contentType: 'application/json',
        data: input,
        success: function(result) {
            alert(JSON.stringify(result));
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

(Lisp beginner) I need to create a 2D array, and initialize each cell in
Beginner question: I would like to pass in window.location.hash to my form action parameter.
Beginner in Symfony2, so maybe it's a dumb question. I would need to get
JS beginner here. I need help with a script to place different content in
Beginner here, I have a simple question. In Android what would be the best
very beginner question. I am using Rails 3's query interface as shown: class User
total beginner to spring mvc. I need to prepopulate edit form in springmvc frame-work.
Beginner Node question. I'm running a Node/Express app, and I want to send client-side
Beginner in JS :) needs an explanation of code piece from Crockford's book ,
how to create a restful webservice using Get and Post method and returning with

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.