Bind to a Web Service

How to: Bind to a Web Service


This example shows how to bind to objects returned by Web service method calls.


This example uses the MSDN/TechNet Publishing System (MTPS) Content Service to retrieve the list of languages supported by a specified document.

Before you call a Web service, you need to create a reference to it. To create a Web reference to the MTPS service using Microsoft Visual Studio, follow the following steps:

  1. Open your project in Visual Studio.

  2. From the Project menu, click Add Web Reference.

  3. In the dialog box, set the URL to

  4. Press Go and then Add Reference.

Next, you call the Web service method and set the DataContext of the appropriate control or window to the returned object. The GetContent method of the MTPS service takes a reference to the getContentRequest object. Therefore, the following example first sets up a request object:

After the DataContext has been set, you can create bindings to the properties of the object that the DataContext has been set to. In this example, the DataContext is set to the getContentResponse object returned by the GetContent method. In the following example, the ItemsControl binds to and displays the locale values of availableVersionsAndLocales of getContentResponse.

For information about the structure of getContentResponse, see Content Service documentation.

© 2016 Microsoft