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

  • Home
  • SEARCH
  • 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 6992849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:41:18+00:00 2026-05-27T19:41:18+00:00

My RESTful WCF 3.5 service accepts an XmlSerialized (as opposed to DataContract serialized) data

  • 0

My RESTful WCF 3.5 service accepts an XmlSerialized (as opposed to DataContract serialized) data object which contains a freeform string field.

The client I wrote (which uses HttpWebRequest / HttpWebResponse to interact with the WCF service) sends XML like this:

<product>
    <description>Foo\r\nBar\r\n\r\nFinal line</description>
</product>

(The CR and LF characters are escaped here for legibility, in reality the raw ASCII bytes 0x0A and 0x0D are sent down the wire, as confirmed with Wireshark).

However my WCF service’s [OperationContract]-marked methods all report that the Product.Description property has the value “Foo\nBar\n\nFinal line”. This happens before any of my code is called.

Somewhere in WCF the \r\n newline characters in strings are being removed and replaced with \n newlines, but I can’t see where or why this is happening.

  • 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-27T19:41:18+00:00Added an answer on May 27, 2026 at 7:41 pm

    That’s actually mandated by the XML specification – http://www.w3.org/TR/REC-xml/#sec-line-ends: “the XML processorMUST behave as if it normalized all line breaks in external parsed entities (including the document entity) on input, before parsing, by translating both the two-character sequence #xD #xA and any #xD that is not followed by #xA to a single #xA character”.

    If you want the “\r” to be preserved, you must escape it (into &#xD;) before sending it to the server, so that it doesn’t get normalized.

    <product>
        <description>Foo&#xD;\nBar&#xD;\n&#xD;\nFinal line</description>
    </product>
    

    If you’re producing this XML with a XmlWriter, you can create one passing a XmlWriterSettings with its NewLineHandling property set to NewLineHandling.Entitize, and this will be done for you.

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

Sidebar

Related Questions

I created a RESTful service using WCF which calculates some value and then returns
I have a wcf restful service with a operation contract that contains two values
I am developing a RESTful WCF service which I then want to consume from
I have a RESTful WCF service (.NET 3.5), which has a function that is
I've created the following RESTful WCF service, which works just fine when running it
In my project, a wcf restful service, which allow users to upload photos to
I would like to implement a high-traffic restful .NET 4.0 WCF service which can
I am creating a Restful WCF web service which will need to be consumed
Being completely new to WCF, I'm trying to make a RESTful service which will
I have wirtten a RESTful WCF Service. Incorporating E-Tags, expires headers. The caching works

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.