void SetupRstChannelFactory()
        {
            IChannelFactory <IRequestChannel> innerChannelFactory = null;
            ChannelBuilder channelBuilder = new ChannelBuilder(this.IssuerBindingContext.Clone(), true);

            // if the underlying transport does not support request/reply, wrap it inside
            // a service channel factory.
            if (channelBuilder.CanBuildChannelFactory <IRequestChannel>())
            {
                innerChannelFactory = channelBuilder.BuildChannelFactory <IRequestChannel>();
                this.requiresManualReplyAddressing = true;
            }
            else
            {
                ClientRuntime clientRuntime = new ClientRuntime("RequestSecurityTokenContract", NamingHelper.DefaultNamespace);
                clientRuntime.ValidateMustUnderstand = false;
                ServiceChannelFactory serviceChannelFactory = ServiceChannelFactory.BuildChannelFactory(channelBuilder, clientRuntime);

                serviceChannelFactory.ClientRuntime.UseSynchronizationContext    = false;
                serviceChannelFactory.ClientRuntime.AddTransactionFlowProperties = false;
                ClientOperation rstOperation = new ClientOperation(serviceChannelFactory.ClientRuntime, "RequestSecurityToken", this.RequestSecurityTokenAction.Value);
                rstOperation.Formatter = MessageOperationFormatter.Instance;
                serviceChannelFactory.ClientRuntime.Operations.Add(rstOperation);

                if (this.IsMultiLegNegotiation)
                {
                    ClientOperation rstrOperation = new ClientOperation(serviceChannelFactory.ClientRuntime, "RequestSecurityTokenResponse", this.RequestSecurityTokenResponseAction.Value);
                    rstrOperation.Formatter = MessageOperationFormatter.Instance;
                    serviceChannelFactory.ClientRuntime.Operations.Add(rstrOperation);
                }
                // service channel automatically adds reply headers
                this.requiresManualReplyAddressing = false;
                innerChannelFactory = new SecuritySessionSecurityTokenProvider.RequestChannelFactory(serviceChannelFactory);
            }

            this.rstChannelFactory = GetNegotiationChannelFactory(innerChannelFactory, channelBuilder);
            this.messageVersion    = channelBuilder.Binding.MessageVersion;
        }
        private void SetupRstChannelFactory()
        {
            IChannelFactory <IRequestChannel> transportChannelFactory = null;
            ChannelBuilder channelBuilder = new ChannelBuilder(this.IssuerBindingContext.Clone(), true);

            if (channelBuilder.CanBuildChannelFactory <IRequestChannel>())
            {
                transportChannelFactory            = channelBuilder.BuildChannelFactory <IRequestChannel>();
                this.requiresManualReplyAddressing = true;
            }
            else
            {
                ClientRuntime clientRuntime = new ClientRuntime("RequestSecurityTokenContract", "http://tempuri.org/")
                {
                    ValidateMustUnderstand = false
                };
                ServiceChannelFactory serviceChannelFactory = ServiceChannelFactory.BuildChannelFactory(channelBuilder, clientRuntime);
                serviceChannelFactory.ClientRuntime.UseSynchronizationContext    = false;
                serviceChannelFactory.ClientRuntime.AddTransactionFlowProperties = false;
                ClientOperation item = new ClientOperation(serviceChannelFactory.ClientRuntime, "RequestSecurityToken", this.RequestSecurityTokenAction.Value)
                {
                    Formatter = MessageOperationFormatter.Instance
                };
                serviceChannelFactory.ClientRuntime.Operations.Add(item);
                if (this.IsMultiLegNegotiation)
                {
                    ClientOperation operation2 = new ClientOperation(serviceChannelFactory.ClientRuntime, "RequestSecurityTokenResponse", this.RequestSecurityTokenResponseAction.Value)
                    {
                        Formatter = MessageOperationFormatter.Instance
                    };
                    serviceChannelFactory.ClientRuntime.Operations.Add(operation2);
                }
                this.requiresManualReplyAddressing = false;
                transportChannelFactory            = new SecuritySessionSecurityTokenProvider.RequestChannelFactory(serviceChannelFactory);
            }
            this.rstChannelFactory = this.GetNegotiationChannelFactory(transportChannelFactory, channelBuilder);
            this.messageVersion    = channelBuilder.Binding.MessageVersion;
        }