What is Address Header in WCF?

Address Header in WCF Service has information which gets sent with every request. It can be used to include any processing logic or routing logic by the end point services.

WCF has the AddressHeader Class for this. This class represents a header which contains address information which can be used to identify and interact with an endpoint.

 

Here is an example which shows how to create address headers, access their properties, add them to a service endpoint and host the service using the endpoint:

 

// Create Address Header

AddressHeader addressHeaders = AddressHeader.CreateAddressHeader("MyServiceName", "http://localhost:8000/service",1);

            

 

// Associate Address Header to an Endpoint

EndpointAddress endpointAddressWithHeaders = new EndpointAddress(

                new Uri("http://localhost/service1"), addressHeaders

                );

 

 

 

 

Reference:

1.       AddressHeader Class