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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:15:42+00:00 2026-05-24T04:15:42+00:00

There is a self hosted WCF REST service, need to send an xml post

  • 0

There is a self hosted WCF REST service, need to send an xml post message to it.
Seems like this question was asked and answered several times, but after trying every solution I still didn`t get any success.

Server: interface

[ServiceContract]
public interface ISDMobileService
{
    [OperationContract]
    [WebInvoke(Method = "POST", BodyStyle=WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Xml, ResponseFormat=WebMessageFormat.Xml)]
    int ProcessMessage(string inputXml);
}

Server: class

public class Service : ISDMobileService
{
    public int ProcessMessage(string inputXml)
    {
        Console.WriteLine( "ProcessMessage : " + inputXml );
        return 0;
     }  
}

Server: hosting

class Program
{
    static void Main(string[] args)
    {
        WebServiceHost          host    =   new WebServiceHost(typeof(Service), new Uri("http://172.16.3.4:7310"));
        WebHttpBinding          webbind = new WebHttpBinding(WebHttpSecurityMode.None);

        ServiceEndpoint         ep      = host.AddServiceEndpoint(typeof(ISDMobileService), webbind, "");
        ServiceDebugBehavior    stp     =   host.Description.Behaviors.Find<ServiceDebugBehavior>();
        stp.HttpsHelpPageEnabled    =   false;

        host.Open();
        Console.WriteLine("Service is up and running. Press 'Enter' to quit >>>");
        Console.ReadLine();

        host.Close();
    }
}

fiddler request

Request from fiddler without anything in the “Request Body” works just fine and fires break point inside ProcessMessage method of Service class, any variant of data in “Request Body”,
e.g.: test || <inputXml>test</inputXml> || inputXml=”test” || <?xml version=”1.0″ encoding=”UTF-8″ ?><inputXml>test</inputXml> etc. gives HTTP/1.1 400 Bad Request

Will appreciate any help with this

  • 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-24T04:15:43+00:00Added an answer on May 24, 2026 at 4:15 am

    A few things:

    • Since you’re using WebServiceHost, you don’t need to explicitly add the service endpoint (call to host.AddServiceEndpoint(...) in your Main.
    • The operation takes a string parameter; if you want to send it in XML, you need to wrap the string in the appropriate element. Try this body and it should work:

    Body:

    <string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">This is a string encoded in XML</string>
    

    You can also send it in different formats, such as JSON. This request should work as well

    POST http://.../ProcessMessage
    Host: ...
    Content-Type: application/json
    Content-Length: <the actual length>
    
    "This is a string encoded in JSON"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a self hosted WCF Rest service that I am using to simulate
I have a Self-Hosted (Console App) WCF REST service with the following binding: WebMessageEncodingBindingElement
There's a WCF self hosted service that must work 99% of time. Sometimes we
There is self - hosted WCF server (Not IIS), and was generated certificates (on
I have a self-hosted WCF service running as a windows service using the WebAPI
I have a self-hosted WCF service and I'm having the following problem: 15 minutes
All attempts to change configuration settings of WCF self hosted service endpoint fail: public
I have a WCF self-hosted service in a Windows Forms application. I am going
I have a self-hosted WCF service (v4 framework) that is exposed through a HttpTransport
I have a single instance WCF service class that is self hosted using a

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.