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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:55:25+00:00 2026-05-26T05:55:25+00:00

In my service contract I have: [OperationContract(Name = TreeViewData)] [WebInvoke(Method = POST, BodyStyle =

  • 0

In my service contract I have:

[OperationContract(Name = "TreeViewData")]
[WebInvoke(Method = "POST", 
BodyStyle = WebMessageBodyStyle.WrappedRequest, 
RequestFormat = WebMessageFormat.Json, 
ResponseFormat = WebMessageFormat.Json)]
TreeData[] TreeViewData(string RagId);

The Tree data class is simple

public interface ITreeDataV1
{
    string Id { get; set; }
    string ParentId { get; set; }
    string Text { get; set; }
    string Value { get; set; }
}

[DataContract(Name = "TreeData", 
Namespace = "http://xxx.com/2011/10/14/TreeDataV1")]
public class TreeData : ITreeDataV1
{
    [DataMember(Name = "Id")]
    public string Id { get; set; }

    [DataMember(Name = "ParentId")]
    public string ParentId { get; set; }

    [DataMember(Name = "Text")]
    public string Text { get; set; }

    [DataMember(Name = "Value")]
    public string Value { get; set; }
}

And in my service logic itself I have:

public TreeData[] TreeViewData(string RagId)
{
// some code and return some array of TreeData           
}

My problem is when I create my jquery $.ajax request as:

$.ajax(
{
type: "POST", 
url: "http://xxx/Retriever.svc/UI/TreeViewData",  
data: {"RagId":"121"},
dataType: "json",
success: function()
    {
        alert('pop the champagne');
    }
}
);

I get the following exception –

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.

I’m almost certain the error is in how I formatted the data bit of the request.

Any pointers?

  • 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-26T05:55:26+00:00Added an answer on May 26, 2026 at 5:55 am

    The entire data object needs to be stringified. An easy way to accomplish this is to use the JSON.Stringify method in the JSON2 library. (https://github.com/douglascrockford/JSON-js/blob/master/json2.js)

    Using it would change it to:

    <script src="JSON2.js" type="text/javascript"></script>
    <script>
        var myObj = {"RagId":"121"};
        var jsondata = JSON.stringify(myObj);
        $.ajax({   
             type: "POST",    
             url: "http://xxx/Retriever.svc/UI/TreeViewData",     
             data: jsondata,   
             dataType: "json",   
             success: function()   
             {   
                alert('pop the champagne');   
             }   
        });  
    </script>
    

    Doing it manually would look something like:

    var data = '{"RagID":"121"}';
    

    However this approach is inflexible and becomes a time waster when trying to manually stringify complex/dynamic objects.

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

Sidebar

Related Questions

I have the following contract: [OperationContract(Name = Upload)] [WebInvoke(Method = POST, UriTemplate = /Upload/{step}/{fileName},
I have a service contract that defines a method with a parameter of type
I have a basicHttpBinding WCF service. Via the contract I expose a method that
I have a simple WCF service method: [OperationContract] public SetupGameResult SetupGame(long player1Id, long player2Id,
Can a class have a Service Contract attribute and its methods Operation Contract. Or
I've seen recommendations (Juval Lowy, et al) that a service contract should have no
I have a WCF service implemented with a call back contract that I am
I have a WCF service that uses Message contract for request and replies of
I have declared two service contracts as follows: [ServiceContract] public interface IContract1 { [OperationContract]
I have a WCF service which I would like to product XML and JSON

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.