Help to choose a binding(WCF)

前端 未结 2 1006
予麋鹿
予麋鹿 2021-01-06 17:32

I need to create WCF Application, which will be working with pictures. It allows you to get a picture as a stream, and to send a picture to server (as a stream). It will wor

相关标签:
2条回答
  • 2021-01-06 17:38

    Check out this blog post (or many other, similar ones)

    The diagram to choose the proper binding is from Juval Lowy's book Programming WCF Services and gives the best guidance, really:

    enter image description here

    Now your additional requirement of streaming limits the number of choices, obviously - net.msmq is out of the question, obviously.

    Streaming is supported by basicHttpBinding, netTcpBinding, and netNamedPipesBinding. The last one probably also is out of the question, since it work on the same machine only (client and server).

    So the choice really boils down to basicHttpBinding vs. netTcpBinding. basicHttp works over http connections and port 80, so it's well suited for internet and "open to the public" scenarios, while netTcp might be a tad faster, but it requires specific ports, which need to be open on server and/or firewalls - so it's probably better suited for corporate LAN environments, but not for the general internet per se.

    Other bindings might come into consideration in very specific scenarios, e.g. you might want to investigate the Relay bindings if you're moving into the cloud, and the Federation bindings if you're looking into federated security - but those don't really apply here when it comes to streaming.

    0 讨论(0)
  • 2021-01-06 17:46

    Streamed response mode is not an optimal mode if you do not have very large streams. Say if your pictures are withing a couple of KB or even upto 100KB you might be better off with buffered transferMode. You can have a stream contract and buffered transfer mode where the whole data is actually buffered across but the data contract enables you to access it like a stream.

    0 讨论(0)
提交回复
热议问题