none
Configuring WCF Services in Code WCF 4.5 RRS feed

  • Question

  • public static void Configure(ServiceConfiguration config) {


    string configPath = ConfigurationManager.AppSettings["wcfconfigDBPath"]; // Enable “Add Service Reference” support config.Description.Behaviors.Add(new ServiceMetadataBehavior { HttpGetEnabled = true }); // set up support for http, https, net.tcp, net.pipe if (isEnabled(configPath, "enablehttp")) config.EnableProtocol(new BasicHttpBinding()); if (isEnabled(configPath, "enablenettcp")) config.EnableProtocol(new NetTcpBinding()); if (isEnabled(configPath, "enablepipe")) config.EnableProtocol(new NetNamedPipeBinding()); } private static bool isEnabled(string path, string elementName) { try { string elementValue = string.Empty; bool returnVal = false; using (XmlTextReader reader = new XmlTextReader(path)) { reader.ReadToFollowing(elementName); if (reader.Read()) elementValue = reader.Value; } if (!string.IsNullOrEmpty(elementValue)) { bool.TryParse(elementValue, out returnVal); } return returnVal; } catch (Exception ex) { return false; } }

    This above code is not working .Am not sure when "static void Configure" gets fired ;

    My question is there any way to enable/disable protocol beased on DB/xml configuration without bringing down the service.


    Thursday, August 15, 2013 4:29 PM

Answers

  • Hi,

    I see that you have post a question in: http://forums.asp.net/t/1929084.aspx . Please try to check the replies.

    If you have any other problem, please let me know.

    Best Regards,
    Amy Peng


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Friday, August 16, 2013 5:58 AM
    Moderator