2010-12-10 170 views
10

爲什麼不WsHttpBinding的支持流?爲什麼不WsHttpBinding的支持流?

編輯:爲了測試我約NetTcpBinding的評論,我想下面的代碼,這使運行時錯誤:

<netTcpBinding > 
     <binding name="myBinding" transferMode="Streamed">   
      <reliableSession enabled="true"/> 
     </binding> 
</netTcpBinding> 

運行時異常:

Unhandled Exception: System.InvalidOperationException: Transfer mode Streamed is 
not supported by ReliableSessionBindingElement. 
    at System.ServiceModel.Channels.ReliableSessionBindingElement.VerifyTransport 
Mode(BindingContext context) 

如果<reliableSession enabled="true"/>被刪除,代碼工作。

+2

因爲他們沒有設計它。 – 2010-12-10 19:30:17

回答

12

WsHttpBinding doesn't support streaming due to the reliable messaging protocol (WS-RM), which requires that messages are buffered on either end.

如前所述here ...約WS-RM更多信息。

還有另一篇文章here提供的推理能夠流相對於上述原因...

This is because WS-RM needs to apply signing/checksums to the whole message as a unity, etc; and this is not possible when streamed transferMode, only with buffered transferMode...

此外netTcpBinding實際上利用了WS-RM的可靠性的目的。

+1

謝謝。任何想法爲什麼WS-RM需要緩衝消息? netTcpBinding提供了可靠性和流媒體,所以我猜測可靠性並不妨礙流媒體。 – morpheus 2010-12-10 20:02:50

+0

@morpheus增加額外的評論...... – 2010-12-10 20:11:35