AbstractChannelFactoryAware worked like a charm!! Thanks.
On Jan 27, 2:48 pm, Craig Neuwirt <[email protected]> wrote: > You should register and IChannelFactoryAware class in the container > e.g > > public class UserNameClientCredentials : AbstractChannelFactoryAware > { > public string UserName { get; set; } > > public string Password { get; set; } > > public override void Created(ChannelFactory channelFactory) > { > channelFactory.Credentials.UserName.UserName = > UserName; > channelFactory.Credentials.UserName.Password = > Password; > } > } > > > > On Wed, Jan 27, 2010 at 12:19 AM, ohaga <[email protected]> wrote: > > I am working on a project where we are using WcfIntegration to create > > client-proxies. Typical code is shown i text below: > > > public void Init() > > { > > var container = new WindsorContainer(); > > container.AddFacility<WcfFacility>(); > > WSHttpBinding binding; > > binding = new WSHttpBinding > > (SecurityMode.TransportWithMessageCredential); > > binding.Security.Message.ClientCredentialType = > > MessageCredentialType.UserName; > > > var endpoint = WcfEndpoint.BoundTo(binding).At("http://localhost/ > > myservice.svc"); > > var defaultClientModel = new DefaultClientModel() > > { > > Endpoint = endpoint > > }; > > var s = typeof (IMyService); > > container.Register(Component.For(s).ActAs(defaultClientModel)); > > } > > > I want to add something like this code: > > var credentials = new ClientCredentials(); > > credentials.UserName.UserName = "username"; > > credentials.UserName.Password = "password"; > > defaultClientModel.AddExtensions(credentials); > > > But I get an error when the channel is created (credentials already > > added). > > > A possible workaround (hack) is to change the code in > > WcfExplicitExtension.Install(ServiceEndpoint endpoint, bool > > withContract, IKernel kernel, IWcfBurden burden) > > { > > object extension = GetExtensionInstance(kernel, burden); > > if (extension is ClientCredentials) > > { > > var config = (ClientCredentials)extension; > > var credentials = endpoint.Behaviors.Find<ClientCredentials>(); > > credentials.UserName.Password = config.UserName.Password; > > credentials.UserName.UserName = config.UserName.UserName; > > } > > else if (extension is IEndpointBehavior) > > { > > endpoint.Behaviors.Add((IEndpointBehavior)extension); > > } > > > Could we use another approach to achieve the same thing? > > > -- > > You received this message because you are subscribed to the Google Groups > > "Castle Project Users" group. > > To post to this group, send email to [email protected] > > . > > To unsubscribe from this group, send email to > > [email protected]<castle-project-users%2Bun > > [email protected]> > > . > > For more options, visit this group at > >http://groups.google.com/group/castle-project-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Castle Project Users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en.
