Can I apply client behaviors to a MetadataExchangeClient to change how it retrieves metadata?
Once a MetadataExchangeClient is built, you don’t have access to its internals to poke around at the description tree. You need to have set things up ahead of time to get the configuration that you want.
One of the constructors for MetadataExchangeClient takes an endpoint configuration name that you can use to point at a client endpoint configuration including the behavior configuration.
public MetadataExchangeClient(string endpointConfigurationName)
However, that doesn’t help if you need to use one of the other constructor options, such as the client mode, or have an existing code implementation that you’re trying to change after the fact.
Because the metadata endpoint is relatively guessable though, you know its address, its binding, and the contract is IMetadataExchange, another approach is to create an endpoint definition matching this triad and let the configuration system pick it up as the default named endpoint. This gets around the need to specify a custom named configuration by changing the problem that’s being solved.