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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:19:28+00:00 2026-05-20T16:19:28+00:00

I have a simple restful wcf service which I have created just for fun.

  • 0

I have a simple restful wcf service which I have created just for fun. I tried the invoke the post method but I am failling. here is the summary;

this is my service contract interface;

namespace WcfServiceWithNortwind.Smooth {

    [ ServiceContract]
    public interface INorthwindService {

        [ WebGet (UriTemplate = "/" )]
        [ OperationContract ]
        List <Category2 > GetCategories();

        [ WebGet (UriTemplate = "categories/{id}" )]
        [ OperationContract ]
        Category2 GetCategory(string id);

        [ WebInvoke (UriTemplate = "categories/{id}" , Method = "DELETE")]
        [ OperationContract ]
        void DeleteCategory(string id);

        [ WebInvoke (UriTemplate = "categories" , Method = "POST")]
        void AddCategory(Category2 category);

    }
}

this is the data members of my service which is Category2 Class;

namespace WcfServiceWithNortwind.Smooth {

    [ DataContract]
    public class Category2 {

        [ DataMember ]
        public int CategoryID { get; set ; }

        [ DataMember ]
        public string CategoryName { get; set ; }

        [ DataMember ]
        public string Description { get; set ; }

    }
}

this is the code which I am trying to invoke the post method;

    System.Xml. XmlDocument doc = new System.Xml. XmlDocument();
    doc.Load(context.Server.MapPath( "~/@xml/category.xml" ));

    string strHostAddress = "http://localhost:54860/Smooth/Nortwind.svc/categories" ;

    string xmldata = doc.OuterXml;
    string _data = String .Format( "{0}{1}", "category=" , xmldata);

    WebRequest _WebRequest = WebRequest .Create(strHostAddress);
    _WebRequest.Method = "POST" ;

    byte [] byteArray = Encoding .UTF8.GetBytes(_data);
    _WebRequest.ContentType = "application/x-www-form-urlencoded" ;
    _WebRequest.ContentLength = byteArray.Length;

    Stream dataStream = _WebRequest.GetRequestStream();
    dataStream.Write(byteArray, 0, byteArray.Length);
    dataStream.Close();

    var _response = _WebRequest.GetResponse();

and this is the xml file that I am using to send which is category.xml;

<? xml version =" 1.0 "?>
<Category2>
  <CategoryID />
  <CategoryName> Tugberk's Category </CategoryName>
  <Description> .net, wcf, wpf, mvc, silverlight </Description>
</Category2>

when I run the code, I am getting the following error as soon as I try to _WebRequest.GetResponse() call;

The incoming message has an
unexpected message format ‘Raw’. The
expected message formats for the
operation are ‘Xml’; ‘Json’. This can
be because a WebContentTypeMapper has
not been configured on the binding.
See the documentation of
WebContentTypeMapper for more details.

I also tried to post it with fiddler with request builder function of it and I got the same error as well.

So what I am missing here guys?

  • 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-20T16:19:28+00:00Added an answer on May 20, 2026 at 4:19 pm

    Make sure you have the header Content-Type: application/xml in your request and either set a namespace on your XML payload or remove the Namespace from your DataContract. Like [DataContract(Namespace=””)]

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created a simple RESTful WCF service with a single method for receiving files
I have a very simple WCF4 Restful web service which uses WcfRestContrib to allow
I have simple form. <form target=_blank action=somescript.php method=Post id=simpleForm> <input type=hidden name=url value=http://...> <input
I've been trying to do a simple restful wcf service that will return JSON.
This might sound strange at first but its rather simple. I have a wcf
I have a simple resftul wcf service. The .svc file looks like this <%@
I have a simple RESTful web service that print Hello World ! I'm using
I have a simple restful service that transforms a JAXB-anntotated beans to response XML
I have a RESTful service that I am developing in WCF . I am
In my project, a wcf restful service, which allow users to upload photos to

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.