The Problem: When writing a web service endpoint in C#, if the return type is a String, the result will be an XML formatted string.
For example, the following web service:
- public String TestServiceA(Stream input)
- {
- return "Some kind of Text";
- }
- <string>Some kind of Text</string>
The Solution: The return type needs to be a Stream.
So now the following web service:
- public Stream TestServiceB(Stream input)
- {
- MemoryStream ms = new MemoryStream();
- StreamWriter sw = new StreamWriter(ms);
- sw.Write("Some kind of Text");
- sw.Flush();
- ms.Position = 0;
- return ms;
- }
- Some kind of Text