Set username credential for a new channel without creating a new factory
- by Ramon
I have a backend service and front-end services. They communicate via the trusted subsystem pattern. I want to transfer a username from the frontend to the backend and do this via username credentials as found here:
http://msdn.microsoft.com/en-us/library/ms730288.aspx
This does not work in our scenerio where the front-end builds a backend service channel factory via:
channelFactory = new ChannelFactory<IBackEndService>(.....);
Creating a new channel is done via die channel factory. I can only set the credentials one time after that I get an exception that the username object is read-only.
channelFactory.Credentials.Username.Username = "myCoolFrontendUser";
var channel = channelFactory.CreateChannel();
Is there a way to create the channel factory only one time as this is expensive to create and then specify username credential when creating a channel?