views:

275

answers:

1

All attempts to change configuration settings of WCF self hosted service endpoint fail:

public void Start()
    {
        BasicHttpBinding binding = new BasicHttpBinding();
        binding.Name = "NAVBinding";
//--------------------START editing-------------------------------
        TimeSpan interval = new TimeSpan(1, 50, 00); // all these following (inbetween comments) lines have no effect
        binding.MaxReceivedMessageSize = 2147483647;
        binding.MaxBufferSize = 2147483647;
        binding.ReceiveTimeout = interval;
        binding.OpenTimeout = interval;
        binding.CloseTimeout = interval;
        binding.SendTimeout = interval;
        XmlDictionaryReaderQuotas readerQuotas = new XmlDictionaryReaderQuotas();
        readerQuotas.MaxDepth = 2147483647;
        readerQuotas.MaxStringContentLength = 2147483647;
        readerQuotas.MaxArrayLength = 2147483647;
        readerQuotas.MaxBytesPerRead = 2147483647;
        readerQuotas.MaxNameTableCharCount = 2147483647;
        binding.ReaderQuotas = readerQuotas;
//----------------------END editing---------------------------
        binding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
        Uri baseAddress = new Uri("http://localhost:8000/nav/customer");
        Customer_Service service = new Customer_Service();
        serviceHost = new ServiceHost(service, baseAddress);
        serviceHost.AddServiceEndpoint(typeof(ICustomer_Service), binding, baseAddress);
        OpenMetadataExchange(baseAddress);
        service.navEventListner = this;
        serviceHost.Open();

    }

but I can easily change the MaxReceivedMessageSize property with the help of wcfStorm application and in this case it really is changed. But after restarting service, everything gets back to its default settings (for example MaxReceivedMessageSize = 65536).

Please, what am I doing whrong? How to edit my code in order new values get updated?

+1  A: 

Setting those values on the SERVER SIDE does not automagically set them on the CLIENT SIDE.

Only setting them on the server side is not enough - the transfer between client and server is dictated by the smallest of the two settings between client and server. Even if the server allows 2 GB of message size, if the client still insists on 64 KB, the smaller value of 64 KB wins. That doesn't mean the 2 GB setting on the server side isn't there - it is, but it's not being effective because the client uses a smaller setting.

If you want to use the same settings on the client side, you will need to configure the client side accordingly. You will need to do the same thing when creating your client proxy, or configure your client from an app.config file.

marc_s
Thank you, Marc, you cleared my vision of this issue. I didn't know about the fact that transfer settings are the smallest ones from the server and client. This unawareness led me to blind attempts without clear understanding. Now I'm able to transfer a data of certainly bigger amount than 65536 (in fact I only removed all settings from my server side app.config file with settings other than that of client side app.config). A problem remained with data of yet bigger size, but it seems because of some another problem which I so far failed to understand. Thanks once again!
rem
@rem: glad I could clear a few things up!
marc_s