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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T08:56:51+00:00 2026-06-16T08:56:51+00:00

Does anyone know whether it is possible to have 2 different endpoints using 2

  • 0

Does anyone know whether it is possible to have 2 different endpoints using 2 different Contract Serializers? Particularly, the default DataContractSerializer for SOAP/XML and Json.NET serializer for REST/JSON

The aim (due compatibilities issues) is to have the same DTO class Person below, serialized into the following JSON and XML formats

DTO Class:

public class Person
{
    public string Name { get; set; }
    public string Surname { get; set; }
}

JSON

{Psn:{"Nm":"name1","Snm":"surname1"}}

XML

<Person><Name>name1</Name><Surname>surname1</Surname></Person>

As can be seen, Response for JSON should contain shrunk property names, but full property names for XML version.

My thoughts were to have both serialisation annotations, those understood by the DataContractSerialiser and those understood by Json.Net serializer i.e. something of this sort:

[DataMember]
[JsonObject(Title="Psn")]
public class Person
{
    [DataMember]
    [JsonProperty(PropertyName="Nm")]
    public string Name { get; set; }

    [DataMember]
    [JsonProperty(PropertyName="Snm")]
    public string Surname { get; set; }
}

I would appreciate any thoughts on how this can be achieved.

  • 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-16T08:56:52+00:00Added an answer on June 16, 2026 at 8:56 am

    The way this was finally implemented was using the WCF Raw Method. http://blogs.msdn.com/b/carlosfigueira/archive/2008/04/17/wcf-raw-programming-model-web.aspx

    Keeping the same DTO mentioned in the question, two operational contracts are created.

    One for SOAP/XML GetPersonResponse GetPerson(GetPersonRequest request) and another one for REST/JSON System.IO.Stream GetPerson_Rest(params...).

    We would go and implement GetPerson() as required. Then in GetPerson_Rest(), we would call GetPerson() afterwhich the returned GetPersonResponse would be converted into Json using JSON.Net library. Finally the method would return a Stream object, as shown in the following snippet:

    string jsonResponse = JsonConvert.SerializeObject(response);
    
    // Serialize into stream of bytes
    byte[] rawResponse = Encoding.UTF8.GetBytes(jsonResponse);
    WebOperationContext.Current.OutgoingResponse.ContentType = "text/plain";
    
    // Return json raw response
    return new MemoryStream(rawResponse);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have quite an uncommon question: Does anyone know whether it is possible to
Does anyone know whether it is possible to refer to another section from the
Does anyone know whether it's possible to modify the workflow actions of a SharePoint
Does anyone know whether it is possible to change the tab order that tabs
Does anyone know whether if its possible to insert binary data into an SQL
Does anyone know whether it is possible (theoretically or in reality) to use the
Does anyone know whether it is possible to programmatically determine the dimensions of the
Does anyone know whether it's possible to change the header text in a Visual
Does anyone know whether it is possible to create a UDDT that is something
Does anyone know whether it's possible to stop Visual Studio 2010 from rearranging its

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.