Monday, June 2, 2008

Add Service Reference in VS 2008

Add Service Reference is a new feature in VS 2008 which primarily makes creating WCF proxy easy. You no longer need to goto Command Prompt and generate proxy files using svcutil.exe. Behind the scenes, Add Service Reference (ASR) calls svcutil.exe, which invokes a service’s MEX endpoint to query for its interfaces and to generate a proxy class and configuration file.

To Add Service Refernce to you WCF do the following steps in Client Visual Studio Project
1. Right Click on the project name and select “Add Service Reference”
2. Make sure your service host is running and the service is up.
3. Enter the service’s Uri into the Add Service Reference Dialog. Upon successful discovery, it will automatically retrieve the metadata (Service Names, Contracts Names, etc) from your service and show them in the dialog
4. Finally provide the Reference name
You dialog should look like this

The next figure shows how Proxy and Configuration files are automatically created
You can understand the differeces between Add Web Reference and Add Service Reference in my next post here

No comments: