The AppendLine method for StringBuilder adds a default line terminator to the end of the added string. The default line terminator is the current value of the Environment.NewLine property, which is "\ r \ n" for non-Unix platforms, or "\ n" for Unix platforms. So what your WebMethod is trying to return looks like this:
"String 1.. \ R \ nLine2. \ R \ nLine3. \ R \ n".
However, the return value is serialized according to the SOAP specifications by truncating "\ r", and the result looks slightly different:
"Line1. \ NLine2. \ NLine3. \ N".
If the service consumer is running on a Windows platform, it probably ignores the single "\ n" character as garbage. Possible solutions:
Encode the return value in a different format, for example. into an array of bytes, therefore: return builder.ToString().ToCharArray();
Replace NewLine with another line that can be provided by the caller, for example. to the BR tag: return builder.Replace(Environment.NewLine, "<br/>").ToString();
Returns an array of strings or any other container with all lines selected.
source share