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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:03:25+00:00 2026-05-18T21:03:25+00:00

Hey, super newbie question. Consider the following WCF function: [ServiceContract] [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] [ServiceBehavior(InstanceContextMode

  • 0

Hey, super newbie question. Consider the following WCF function:

[ServiceContract]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
public class Service1
{
     private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();

     [WebInvoke(UriTemplate = "", 
                Method = "POST", 
                ResponseFormat = WebMessageFormat.Json,
                RequestFormat = WebMessageFormat.Json,
                BodyStyle = WebMessageBodyStyle.Bare) ]
     public SomeObject DoPost(string someText)
     {
          ...
          return someObject;

In fiddler what would my request headers and body look like?

Thanks for the help.

  • 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-18T21:03:25+00:00Added an answer on May 18, 2026 at 9:03 pm

    I’ve slightly changed your WCF service to have a better example and written a sample test program (see below).

    The first test executes a GET request for the URL http://localhost:57211/Service1.svc/getcar/1. The 1 at the end is a parameter. The port number may be different in your case. The result is:

    {"ID":1,"Make":"Porsche"}
    

    The second test executes a POST request by sending the same data (except Ferrari for Porsche) to the URL http://localhost:57211/Service1.svc/updatecar/1. The result is:

    {"ID":1,"Make":"Ferrari"}
    

    This request has both a parameter in the URL (the 1) plus the request data (a JSON structure) as a second parameter, transmitted as the request body.

    With a network debugger, it would look like this (simplified):

    POST /Service1.svc/updatecar/1 HTTP/1.1
    Host: localhost:57211
    Content-Type: application/json
    Content-Length: 25
    
    {"ID":1,"Make":"Ferrari"}
    
    HTTP/1.1 200 OK
    Server: ASP.NET Development Server/10.0.0.0
    Date: Sat, 25 Dec 2010 19:16:19 GMT
    Content-Length: 25
    Content-Type: application/json; charset=utf-8
    
    {"ID":1,"Make":"Ferrari"}
    

    I hope that helps.

    TestService.cs:

    class TestService
    {
        static void Main(string[] args)
        {
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://localhost:57211/Service1.svc/getcar/1");
            WebResponse response = request.GetResponse();
            string result = new StreamReader(response.GetResponseStream()).ReadToEnd();
            Console.WriteLine(result);
    
            string requestData = "{\"ID\":1,\"Make\":\"Ferrari\"}";
            byte[] data = Encoding.UTF8.GetBytes(requestData);
            request = (HttpWebRequest)WebRequest.Create("http://localhost:57211/Service1.svc/updatecar/1");
            request.Method = "POST";
            request.ContentType = "application/json";
            Stream dataStream = request.GetRequestStream();
            dataStream.Write(data, 0, data.Length);
            dataStream.Close();
    
            response = request.GetResponse();
            result = new StreamReader(response.GetResponseStream()).ReadToEnd();
            Console.WriteLine(result);
        }
    }
    

    IService.cs:

    [ServiceContract]
    public interface IService1
    {
        [OperationContract]
        [WebGet(ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Bare,
            UriTemplate = "/getcar/{id}")]
        Car GetCar(string id);
    
        [OperationContract]
        [WebInvoke(RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Bare,
            UriTemplate = "/updatecar/{id}")]
        Car UpdateCar(string id, Car car);
    }
    
    
    [DataContract]
    public class Car
    {
        [DataMember]
        public int ID { get; set; }
    
        [DataMember]
        public string Make { get; set; }
    }
    

    Service.svc:

    public class Service1 : IService1
    {
        public Car GetCar(string id)
        {
            return new Car { ID = int.Parse(id), Make = "Porsche" };
        }
    
    
        public Car UpdateCar(string f, Car car)
        {
            return car;
        }
    }
    

    Service1.svc (Markup):

    <%@ ServiceHost Language="C#" Debug="true" Service="JSONService.Service1" CodeBehind="Service1.svc.cs" Factory="System.ServiceModel.Activation.WebServiceHostFactory" %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey all. Newbie question time. I'm trying to setup JMXQuery to connect to my
Hey Everyone, import android.widget.Button; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.webpage); but_action =
Hey so I installed IR_Black.terminal using the tutorial here: http://blog.toddwerth.com/entries/13 And it's super simple.
Hey guys, I have this code within a function inside a class that is
Hey everyone, I'm a newbie and I have what I anticipate will be a
Hey, thanks in advance for the help. I have another pretty straight forward question.
Hey im having this code so far - (id)initWithDictionary:(NSDictionary *)aDictionary { self = [super
Hey Guys I have the following simple Code : WhereAmIViewController.h #import <UIKit/UIKit.h> #import <CoreLocation/CoreLocation.h>
Hey guys ive got the following code in my Model require 'RMagick' class Upload
Hey everyone, I'm using Virtual PC and working with a virtual hard disk (*.vhd)

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.