none
basicHttpBinding Runtime Override RRS feed

  • Question

  • I need to tweak a couple settings in my basicHttpBinding at runtime. I don't want to create my own entirely new binding, I just want to find the existing basicHttpBinding that was loaded by the service at runtime from the config, and change a couple settings on that binding.

    There are all kinds of examples of how to build my own brand new binding at runtime but I can't find any examples of how to grab the existing one that was loaded from the config file.

    Thanks

    Tuesday, March 25, 2014 4:00 AM

All replies

  • Hi,

    Please try to use the following code to grab the existing basicHttpBinding that was loaded from the service config file:

     public  BasicHttpBinding readbasicHttpbinding()
            {
                var config = ConfigurationManager.GetSection("system.serviceModel/bindings") as
                            System.ServiceModel.Configuration.BindingsSection;
                foreach(ServiceEndpointElement bindings in config.BasicHttpBinding.Bindings)
                {
                    string binding = bindings.Binding;
    
                    if (binding != null)
                    {
                        return new BasicHttpBinding(binding);
                    }
    
                    
                }
                return null;
            }
    

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, March 26, 2014 2:59 AM
    Moderator
  • Hi Amy, thank you very much for the idea. I had not thought about pulling it right out of the config. That doesn't seem quite right, but it did make me realize what I was missing! I'll post the code when I finish it. Hopefully tomorrow.

    Thanks again!

    Wednesday, March 26, 2014 4:04 AM
  • Hi,

    Have you finished the code? Do you mind to post the code here to help the others who meet the same question as you?

    Thank you very much!

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, April 1, 2014 2:02 AM
    Moderator
  • Sorry, unfortunately what I'd hoped would work did not. I'm still stuck with handling it in the configuration file. I know there has to be a way to loop through the endpoints at runtime, get the basicHttp endppint, and tweak the values, but I haven't got it yet.
    Tuesday, April 1, 2014 2:11 AM