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].
For more options, visit this group at
http://groups.google.com/group/castle-project-users?hl=en.