I'm creating a custom behaviour for WCF which can (for interoperability reasons) only function correctly when a service exposes a single application endpoint.
I would like to be able to use the IServiceBehavior.Validate
method to check that only one application endpoint is exposed by the service. Currently I'm doing the following:
public void Validate(
ServiceDescription serviceDescription,
ServiceHostBase serviceHostBase)
{
if (serviceDescription.Endpoints.Count > 1)
{
throw new InvalidOperationException();
}
}
serviceDescription.Endpoints
unfortunately contains all the endpoints, including the IMetadataExchange
endpoint. This causes the validation to fail on perfectly valid services.
What I need is a way to only count the application (non-infrastructure) endpoints, but I cannot find how WCF itself determines which are which.