2014-03-31 35 views
1

我在嘗試將netTcpBinding轉換爲customBinding如何將netTcpBinding轉換爲customBinding?

這裏是NetTcpBinding的配置:

<netTcpBinding> 
    <binding name="DuplexBinding" sendTimeout="00:00:30" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"> 
     <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/> 
     <reliableSession enabled="true" ordered="true"/> 
     <security mode="Message"> 
     <message clientCredentialType="UserName"/> 
     </security>      
    </binding> 
</netTcpBinding> 

我創建了一個CustomDuplexBinding

<customBinding> 
    <binding name="CustomDuplexBinding" sendTimeout="00:00:30"> 
     <transactionFlow /> 
     <reliableSession ordered="true"/> 
     <security authenticationMode="UserNameForCertificate" enableUnsecuredResponse="true"> 
     <secureConversationBootstrap authenticationMode="UserNameForCertificate" /> 
     </security> 
     <compositeDuplex /> 
     <oneWay /> 
     <binaryMessageEncoding> 
     <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" 
         maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/> 
     </binaryMessageEncoding> 
     <sslStreamSecurity requireClientCertificate="false"/> 
     <tcpTransport maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"/> 
    </binding> 
</customBinding> 

但是當我運行,以下異常已發生:

綁定「CustomDuplexBind ing'不支持創建任何通道類型。 這通常表示CustomBinding中的BindingElements有 堆疊不正確或順序錯誤。在堆棧底部需要一個Transport爲 。 BindingElements的推薦順序是:TransactionFlow,ReliableSession,Security, CompositeDuplex,OneWay,StreamSecurity,MessageEncoding,Transport。

任何人都可以請幫我解決這個問題嗎?

+0

您是否嘗試切換''和''的順序? – Tim

+0

我試圖切換順序並得到異常:「_ Binding'CustomBinding',TransportBindingElement'TcpTransportBindingElement'不會出現在BindingElementCollection的最後,請更改元素的順序,使TransportBindingElement爲last_。」 – Dmitriy

回答

0

從錯誤信息: 「...... StreamSecurity,MessageEncoding ......」

在你的綁定congifuration,你接着<sslStreamSecurity><<binaryMessageEncoding>。這些都需要進行切換:

<sslStreamSecurity requireClientCertificate="false"/> 
<binaryMessageEncoding> 
    <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" 
       maxArrayLength="2147483647" maxBytesPerRead="2147483647" 
       maxNameTableCharCount="2147483647"/> 
</binaryMessageEncoding> 

Custom Bindings MSDN上,下面是要求的順序

  • 交易流程
  • 可靠的會話
  • 安全
  • 複合複式
  • 單程
  • 流安全
  • 郵件編碼
  • 交通運輸

只有最後兩(郵件編碼和傳輸)是必需的;其餘是可選的。

+0

我嘗試過幾種組合,但沒有得到任何結果。所需的訂單不起作用。我已經刪除了安全元素併成功啓動了服務。我不知道安全有什麼問題。謝謝您的幫助! – Dmitriy

1

我一直有這個相同的問題。雖然Stream Security和Message Encoding元素在原始帖子中倒退,但即使它們按正確的順序也會發生相同的錯誤。對我來說,問題在於安全元素上使用的authenticationMode。我的nettcp安全元素與原始發佈者的相同(具有用戶名驗證的消息安全性)。使用此工作:

<security authenticationMode="SecureConversation"> 
    <secureConversationBootstrap authenticationMode="UserNameForSslNegotiated" /> 
</security> 
相關問題