You cannot do this, see this documentation.
At least one of the parameter and return value types must be either Stream, Message, or IXmlSerializable.
So, as you wrote it, it will not work for TransferMode.Streamed , however, nothing in this link explicitly says that a property of type Stream will not be serialized, but from experience I would not expect this to work.
Instead, you should return Stream and define the first x bytes as the field of your Info string.
[ServiceContract()] public interface IService { [OperationContract] Stream GetData(); }
so when writing to a stream (server side) you would do
stream.Write(infoStr);//check size and truncate if appropriate stream.Write(fileBytes);//write your file here
Then on the other hand, you need to read from correctly in order to get data from the stream. I would suggest writing 2 int to the stream first. The first will be the size of your infoStr field, and the second will be the size of your file. For the size of the client, you first read them, then you know how many bytes you need to read.
source share