Tengo un cliente dinámico para un servicio. ¿Cómo puedo cambiar la propiedad ReaderQuotas de su enlace de punto final?Modifique endpoint ReaderQuotas programmatically
traté como este, pero no funciona ...
DynamicProxyFactory factory = new DynamicProxyFactory(m_serviceWsdlUri);
foreach (ServiceEndpoint endpoint in factory.Endpoints)
{
Binding binding = endpoint.Binding;
binding.GetProperty<XmlDictionaryReaderQuotas>(new BindingParameterCollection()).MaxArrayLength = 2147483647
binding.GetProperty<XmlDictionaryReaderQuotas>(new BindingParameterCollection()).MaxBytesPerRead =2147483647;
binding.GetProperty<XmlDictionaryReaderQuotas>(new BindingParameterCollection()).MaxDepth = 2147483647;
binding.GetProperty<XmlDictionaryReaderQuotas>(new BindingParameterCollection()).MaxNameTableCharCount = 2147483647;
binding.GetProperty<XmlDictionaryReaderQuotas>(new BindingParameterCollection()).MaxStringContentLength = 2147483647;
}
Incluso después de hacer esto, los valores permanecen ReaderQuotas la falta de pago.
también probé así y todavía no funciona:
DynamicProxyFactory factory = new DynamicProxyFactory(m_serviceWsdlUri);
foreach (ServiceEndpoint endpoint in factory.Endpoints)
{
System.ServiceModel.Channels.BindingElementCollection bec = endpoint.Binding.CreateBindingElements();
System.ServiceModel.Channels.TransportBindingElement tbe = bec.Find<System.ServiceModel.Channels.TransportBindingElement>();
tbe.MaxReceivedMessageSize = 2147483647;
tbe.MaxBufferPoolSize = 2147483647;
TextMessageEncodingBindingElement textBE = bec.Find<TextMessageEncodingBindingElement>();
if (textBE != null)
{
textBE.ReaderQuotas.MaxStringContentLength = 2147483647;
textBE.ReaderQuotas.MaxArrayLength = 2147483647;
textBE.ReaderQuotas.MaxBytesPerRead = 2147483647;
textBE.ReaderQuotas.MaxDepth = 2147483647;
textBE.ReaderQuotas.MaxNameTableCharCount = 2147483647;
}
}
necesito esto, así que puede enviar más de 8 kb para el servicio.
+1 por mencionar estas cosas tienen que ser establecido antes de crear el proxy de cliente y/o host de servicio. Una vez creados, son inmutables. –
Hola Marc, Gracias por la respuesta, pero no sé qué tipo de enlace es, por eso tengo que hacerlo después de crear el enlace. ¿Alguna otra sugerencia? Gracias, Adrya – Adrya
¿Qué quieres decir con que no sabes qué tipo de encuadernación es? En ServiceHostFactory, solo mire en el enlace y modifique la cuota si es necesario. Si lo que dices es que no sabes que debes modificar la cuota hasta después de USAR el enlace, entonces ... puedes establecer un indicador y luego reiniciar el servidor (o servidor cliente). – Cheeso