Mặc dù tự tạo kênh và tự phát hành mã thông báo với STS không đúng, bạn có thể tận dụng khung công tác WIF để thực hiện việc này cho bạn.
Nếu bạn định cấu hình ứng dụng khách thông qua cấu hình để biết STS, khung sẽ tự truy xuất mã thông báo bằng thông tin đăng nhập bạn đã đặt trên kênh. Sau đó, khung sẽ đặt thuộc tính "IssuedToken" trên thông tin đăng nhập của kênh.
<ws2007HttpBinding>
<binding name="ws">
<security mode="TransportWithMessageCredential">
<message establishSecurityContext="false"
negotiateServiceCredential="true"
clientCredentialType="UserName" />
</security>
</binding>
</ws2007HttpBinding>
<customBinding>
<binding name="FederationDuplexTcpMessageSecurityBinding">
<reliableSession />
<security authenticationMode="SecureConversation">
<secureConversationBootstrap authenticationMode="IssuedTokenForSslNegotiated">
<issuedTokenParameters>
<issuer address="https://IdentityServer.domain/issue/wstrust/mixed/username" binding="ws2007HttpBinding" bindingConfiguration="ws" />
<issuerMetadata address="https://IdentityServer.domain/issue/wstrust/mex" />
<additionalRequestParameters>
<wsp:AppliesTo xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
<EndpointReference xmlns="http://www.w3.org/2005/08/addressing">
<Address>RelyingParty.com</Address>
</EndpointReference>
</wsp:AppliesTo>
</additionalRequestParameters>
</issuedTokenParameters>
</secureConversationBootstrap>
</security>
<tcpTransport />
</binding>
</customBinding>
Đoạn mã trên cho thấy cách bạn có thể tạo kênh song công bằng cách sử dụng Cuộc trò chuyện bảo mật và secureConversationBootstrap để quản lý bảo mật liên kết.
Một lợi thế của việc này là bạn cũng có thể thiết lập URI của bên phụ thuộc của riêng bạn, vì vậy bạn không phải sử dụng điểm cuối WCF làm định danh của bên phụ thuộc của bạn.
Bạn cũng sẽ cần phải thiết lập các hành vi dịch vụ liên để cho phép WIF như sau (useIdentityConfiguration là quan trọng, vì nó biến WIF trên):
<behavior name="FederatedServiceBehaviour">
<clientCredentials useIdentityConfiguration="true" supportInteractive="false" >
<serviceCertificate/>
</clientCredentials>
</behavior>
lập endpoint dịch vụ được ghi nhận ở đây: http://msdn.microsoft.com/en-us/library/cc668765(v=vs.110).aspx (đến một mức độ)
Theo tôi có thể thấy bản thân DuplexChannelFactory không có phương pháp tạo kênh với mã thông báo đã phát hành trong khi đi qua ngữ cảnh cá thể.
Hy vọng điều này sẽ hữu ích!