The carriage return "\ r" in WebService in C # is missing.

Source: Internet
Author: User

Assume that the following WebService method is defined:

 

 

Code
/// <Summary>
/// Calculate the length
/// </Summary>
/// <Param name = "text"> </param>
/// <Returns> </returns>
[WebMethod]
Public int GetLen (string text)
{
Return text. Length;
}

 

If the transmitted string text contains the "carriage return newline" character, that is, "\ r \ n", after being transmitted by WebService in C. "\ r" will disappear from the data received by the server !! That is, there are only one byte in "\ r \ n.

 

This BUG is really depressing today (the length before sending is not the same as the received length, resulting in the final signature mismatch, and the data can only be Base64 to Solve the Problem )...

 

Note:According to the link given by Wu meibo <active target. Net>, we know that the cause of the character loss is determined by the XML specification. Thank you for choosing :)

Http://xml.coverpages.org/xml10-chinese.html#sec-line-ends

Code
2.11 lines at the end
For the convenience of editing, computer files that store parsed XML objects are often organized in rows. These lines are usually separated by a combination of carriage returns (# xD) and line breaks (# xA.

To simplify the application work, any two-character constant sequence "# xD # xA" or a separate constant # xD, all XML processors should be replaced with # xA and passed to the application. (This can be achieved by standardizing all row separators into # xA before syntax analysis .)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.