WCF - Reading from Application Configuration File - config section - system.serviceModel

I can't find any example on the web for this, so i guess it could be helpful.
This is a simple example to show a way to read the system.serviceModel configuration section in application/web configuration file.

Something like for
ConnectionString, there is a straightforward class for that,
ConfigurationManager.ConnectionStrings["keyname"].ConnectionString

Codes snippet below

ServiceModelSectionGroup group = ServiceModelSectionGroup.GetSectionGroup(ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None));

//suppose if there is only one endpoint
if(group.Client.Endpoints.Count < 0)
{
uri = group.Client.Endpoints[0].Address.AbsoluteUri;
}

Comments

Popular posts from this blog

Outlook : "operation failed, object could not be found. " when trying to close a PST.

How to transfer app and data from old iPhone to new iPhone for model IOS17 and IOS18 above.

Tips on how to use IBM iNotes (web client) on emailing or scheduling - Like copy tables from Excel or checking for user id (windows logon id) through email address