I have a WCF service where I would like to send a log file and process it on the server.
The contract is:
[OperationContract]
void LogFile(Stream file);
And Im using StreamedRequest in the endpoint.
The problem I have is that I cant find a way to read the stream in the service.
When I debug the call, I see that the Stream is an instance of:
System.ServiceModel.Dispatcher.StreamFormatter.MessageBodyStream
From the client Im sending a MemoryStream.
So… How can I read the stream?
Thanks.
Edit1:
im using:
Stream serviceStream = new MemoryStream();
byte[] buffer = new byte[10000];
int bytesRead = 0;
do
{
bytesRead = file.Read(buffer, 0, buffer.Length);
serviceStream.Write(buffer, 0, bytesRead);
} while (bytesRead > 0);
serviceStream.Position = 0;
to read the stream, nothing gets out, always 0
My bad, in the client I forgot to set the position of the stream to 0, so the service was getting the stream with the position at the end of it