I need to understand how does WCF works when sending a message. Does WCF serialize everything before sending it?
My other question is which will be the benefit of using Streaming? Is it better for bigger messages, lets say between 1Mb to 2Mb? Can I send a complex object serialized, and then be able to deserialize it in the other side easily after streaming (by complex object I mean a List of images that can be dynamic), or do I need to format it using something like XML?
The main issue here is that I don't know if when using WFC streaming, I need to serialize the message first before sending it... i开发者_开发知识库sn't WFC supposed to serialize everything before sending it?
I know is very general, but I need to clarify these concepts.
Cheers
- Yes, apart from streams.
- Streaming allows you to implement what normally would be difficult or impossible. For example if you try to send a 500MB using HTTP binding, this would be impossible. But using streaming, you get a pointer to a stream and you can read from the stream.
- It seems that you are referring to Buffered approach rather than streaming. Yes, you can set it to buffered and is preferred for large messages.
- Yes, you can stream a buffer and then use your own serialisation to deserialise.
In streaming, you send a stream and allow the other side to read from it, no serialisation is required. For example:
interface IMyService { Stream GetMyFile(Guid fileId); }
and
class MyService : IMyService
{
Stream GetMyFile(Guid fileId)
{
return new FileStream(GetFileNameFromId(fileId), ...);
}
}
精彩评论