The first thing to do is configure what you can in the configuration file, in my case it was setting up the wsHttpBinding.
<ws2007HttpBinding>
<binding name="MyCustomServiceBinding">
<security mode="Message">
<message clientCredentialType="Certificate" negotiateServiceCredential="false" establishSecurityContext="false" />
</security>
</binding>
</ws2007HttpBinding>
public class MyCustomEndPointBehavior : IEndpointBehavior
{public void Validate(ServiceEndpoint endpoint) {}
public void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters)
{var serviceCredentials = bindingParameters.Remove<ServiceCredentials>();
serviceCredentials = serviceCredentials == null ? new ServiceCredentials() : serviceCredentials.Clone();
serviceCredentials.ServiceCertificate.Certificate = new X509Certificate2(@"C:\FilePath\Cert.pfx","CertPassword",X509KeyStorageFlags.MachineKeySet);
bindingParameters.Add(serviceCredentials);
}
public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher) {}
public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime) {}
}
Finally we need to wire the end point behaviour into Windsor, this is as simple as registering the type.
var myCustomEndpointBehavior = new MyCustomEndPointBehavior();container.AddFacility<WcfFacility>().Register(
Component.For<IEndpointBehavior>().Instance(myCustomEndpointBehavior),
Component.For<IMyCustomService>().ImplementedBy<MyCustomService>());
DefaultServiceHostFactory.RegisterContainer(container.Kernel);
