Why doesn't the WCF Binding class have a ReaderQuotas member?
I'm wondering why the binding class in WCF does not have a ReaderQuotas property , but its BasicHttpBinding and WSHttpBinding subclasses do.
This fact makes coding a little more difficult. For me, I am using below code to extract binding information from MEX endpoint URI. However, it just got a bind. If I want to change the ReaderQuotas binding, I have to subclass it Binding , but I can't figure out the exact binding at runtime.
public static void LoadMex(string serviceMexUri,
ContractDescription contract,
out EndpointAddress endpointAddress,
out Binding serviceBinding)
{
EndpointAddress mexAddress = new EndpointAddress(serviceMexUri);
MetadataExchangeClient mexClient = new MetadataExchangeClient(mexAddress);
mexClient.ResolveMetadataReferences = true;
mexClient.OperationTimeout = TimeSpan.FromSeconds(30);
MetadataSet metaSet = mexClient.GetMetadata();
WsdlImporter importer = new WsdlImporter(metaSet);
ServiceEndpointCollection endpoints = importer.ImportAllEndpoints();
foreach (ServiceEndpoint ep in endpoints)
{
// we just use one endpoint for now.
if ((ep.Contract.Namespace == contract.Namespace) &&
(ep.Contract.Name == contract.Name))
{
endpointAddress = new EndpointAddress(ep.Address.Uri);
serviceBinding = ep.Binding;
return;
}
}
throw new ApplicationException(String.Format("no proper endpoint is found from MEX {0}", serviceMexUri));
}
Does anyone know why WCF is designed this way?
Is there a way to get around this limitation?
source to share
The reason is that bindings are designed to work as a general communication infrastructure, and ReaderQuotas is a specific SOAP object. This is why you only see this on bindings that are intended to be used with SOAP message transfers.
A how-to to try and cast the types you want to support is probably your best bet.
source to share