Configure WCF Service Endpoint dynamically – Easy WCF
Skip to content

Configure WCF Service Endpoint dynamically

We can configure WCF service endpoint in 2 ways.

  • Declare in configuration file
  • Dynamically in code

Declare in configuration file:

You can declare the endpoints declaratively in WCF service. we will take example of Hello Service.In app.config, you will see the end point.

Also you will have a service behavior where you will be defining the service metadata exchange.

Then if you will run the service it would work fine.

Dynamically in code:

Lets see how we need to define the endpoints dynamically in code.

Delete the endpoint and service behaviors from configuration file.
Then in HelloServiceHost, we need to add the endpoints before opening the host in program.cs

You need to use System.ServiceModel.Description namespace for using ServiceMetadataBehavior.

Now if you will run the client, it will work fine.

© 2015, admin. All rights reserved.

One thought on “Configure WCF Service Endpoint dynamically

  1. Umesh says:

    Nice Article !!!!!!!!

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *