13 September 2012

WCF Client Retrieving Endpoint definition

When we take a reference of a service at the client side, the client automatically generates endpoint definitions from WSDL. It can generate two things :
a. Code containing an equivalent service contract definition
b. Config information containing the endpoint definition

Let us take the following example : 


Here we have a service exposing several endpoints in the form of WSDL definition. Client retrieves that using metadata import tool, which generates two things : 
a. configuration file containing the client side endpoint definitions. 
b. .net contract definitions in the code format

These two things need to be compiled at the client side application & thus the programming model becomes symmetric to what is there at the service side.

How to do : 
1. Right click on the client project, add reference. 

2. Type the address of your metadata and hit enter. This will download the metadata and generate the code in the configuration file necessary for your client side endpoints.

3. Thus it automatically add those code lines and configuration in the project for you by merging the configuration file.

4. Finally it add a new thing in your project called a service reference.

No comments:

Post a Comment