WCF: Serialization? Streaming?

I need to understand how WCF works when sending a message. Does WCF share everything before sending?

My other question is what would be useful to use Streaming? Is this better for large messages, say between 1Mb to 2Mb? Can I send a complex object serialized and then easily deserialize it on the other side after streaming (I call a list of images a complex object that can be dynamic), or do I need to format it using something like XML?

The main problem here is that I don’t know, when using WFC streaming, I need to serialize the message first before sending ... shouldn't WFC serialize everything before sending?

I know, very general, but I need to clarify these concepts.

Greetings

+4
source share
1 answer
  • Yes, except for streams.
  • Streaming allows you to implement what would normally be difficult or impossible. For example, if you try to send 500 MB using an HTTP binding, that would not be possible. But with streaming, you get a pointer to the stream, and you can read it from the stream.
  • It seems that you are referring to the Buffered approach, not the streaming one. Yes, you can configure it to buffer and prefer large messages.
  • Yes, you can pass a buffer and then use your serialization to deserialize.
  • In streaming, you send a stream and allow the other side to read it; serialization is not required. For instance:

    IMyService interface {Stream GetMyFile (Guid fileId); }

and

class MyService : IMyService { Stream GetMyFile(Guid fileId) { return new FileStream(GetFileNameFromId(fileId), ...); } } 
0
source

All Articles