Export (0) Print
Expand All

How to: Add, Update, or Remove a Service Reference

A service reference enables a project to access one or more Windows Communication Foundation (WCF) services. Use the Add Service Reference dialog box to search for WCF services in the current solution, locally, on a local area network, or on the Internet.

To add a reference to an external service

  1. In Solution Explorer, right-click the name of the project that you want to add the service to, and then click Add Service Reference.

    The Add Service Reference dialog box appears.

  2. In the Address box, enter the URL for the service, and then click Go to search for the service. If the service implements username/password security, you may be prompted for a username and password.

    Note Note

    You should only reference services from a trusted source. Adding references from an untrusted source may compromise security.

    Note Note

    You can also select the URL from a drop-down list that stores the last 15 URLs where valid service metadata was found.

    A progress bar is displayed while the search is being performed. You can stop the search at any time by clicking Stop.

  3. In the Service list, expand the node for the service that you want to use and select a service contract.

  4. In the Namespace box, enter the namespace that you want to use for the reference.

  5. Click OK to add the reference to the project.

    A service client (proxy) is generated, and metadata describing the service is added to the app.config file.

To add a reference to a service in the current solution

  1. In Solution Explorer, right-click the name of the project that you want to add the service to, and then click Add Service Reference.

    The Add Service Reference dialog box appears.

  2. Click Discover.

    All WCF services in the current solution are added to the Service list.

  3. In the Service list, expand the node for the service that you want to use and select a service contract.

  4. In the Namespace box, enter the namespace that you want to use for the reference.

  5. Click OK to add the reference to the project.

  6. A service client (proxy) is generated, and metadata describing the service is added to the app.config file.

Over time, the metadata for a WCF service may change, requiring that the service reference be updated.

To update a service reference

  • In Solution Explorer, right-click the service reference and then click Update Service Reference.

    A progress dialog box is displayed while the reference is updated from its original location, and the service client is regenerated to reflect any changes in the metadata.

If a service reference is no longer being used, you can remove it from your solution.

To remove a service reference

  • In Solution Explorer, right-click the service reference and then click Delete.

    The service client will be removed from the solution, and the metadata describing the service will be removed from the app.config file.

    Note Note

    Any code that references the service reference will have to be removed manually.

Show:
© 2014 Microsoft