[英]Custom Binding WCF with tcpTransport
我有一個WCF服務托管在Windows服務上,該服務使用自己的憑據在同一網絡上運行。 安全性並不重要。 但是,速度和可靠性很重要。
因此,我嘗試使用netTcpBinding
綁定。 但是,我注意到當我將服務引用到客戶端時。 它將identity
標簽添加到配置文件中,該標簽包含運行服務的帳戶的信息:
<identity>
<userPrincipalName value="account@domain" />
</identity>
我真的不想在客戶端的配置文件中使用它,也不想以編程方式傳遞它。
當我改用basicHttpBinding
,我注意到它沒有添加該標簽。 但是,我仍然要堅持使用net.tcp。 因此,我的下一個嘗試是使用customBinding
所以,這就是我的問題所在。 我無法引用到客戶端的自定義綁定。 有人可以驗證我的配置嗎? 也。 這足以完全忽略身份標簽嗎? 如果這不是正確的方法,那將是正確的方法? 謝謝
<system.serviceModel>
<services>
<service name="LicenseServiceLogic.LicenseService">
<endpoint address="net.tcp://localhost:8000/LicenseService"
binding="myCustomBinding"
contract="LicenseServiceLogic.ILicenseService">
</endpoint>
</service>
</services>
<bindings>
<customBinding>
<binding name="myCustomBinding">
<compactMessageEncoding>
<binaryMessageEncoding/>
</compactMessageEncoding>
<tcpTransport listenBacklog ="100"
maxBufferPoolSize ="524288"
maxBufferSize ="2147483647"
maxReceivedMessageSize ="2147483647"/>
</binding>
</customBinding>
</bindings>
<client>
<endpoint binding="customBinding"
bindingConfiguration="myCustomBinding"
contract="IMetadataExchange"
name="http" />
</client>
</system.serviceModel>
首先,我們無法引用到客戶端的自定義綁定的原因是我們應該添加MEX服務端點並啟用服務元數據行為。 像下面一樣
<system.serviceModel>
<services>
<service name="VM1.MyService" behaviorConfiguration="mybehavior">
<endpoint address="" binding="netTcpBinding" contract="VM1.IService" bindingConfiguration="mybinding">
</endpoint>
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" ></endpoint>
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:5566"/>
</baseAddresses>
</host>
</service>
</services>
<bindings>
<netTcpBinding>
<binding name="mybinding">
<security mode="None"></security>
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="mybehavior">
<serviceMetadata />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
此外,如果我們不想在客戶端配置中添加身份標簽,則只需將“安全模式”設置為“無”即可。 如上圖所示。
有關Mex端點的詳細信息。
https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/metadata
請隨時告訴我是否有什么我可以幫助的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.