Share via


Client Settings Web Services Sample

This sample demonstrates how to use a Web service client to retrieve application settings. This sample includes a Web service and its corresponding client. You should first install the Web service and then build the Web service client.

For information about using samples, see the following topics:

Caution noteCaution

The simple API implemented in the associated Web service enables the caller to specify which application's settings to fetch for that authenticated user. This should not be considered secure for production applications, because other applications running on the user's computer may be able to spoof this application by getting the provider to pass in a different application name. Also, a direct call to the Web service outside of the application context may be able to pass itself off as another application.

Security noteSecurity Note

This sample code is provided to illustrate a concept and should not be used in applications or Web sites, as it may not illustrate the safest coding practices. Microsoft assumes no liability for incidental or consequential damages should the sample code be used for purposes other than as intended.

To install the Web service

  1. Create a WebSettings directory under the WWWRoot directory of your Internet Information Services (IIS) installation.

    For example, if your root is D:\InetPub\WWWRoot\, create the directory D:\InetPub\WWWRoot\WebSettings.

  2. Copy the contents of WebService into this directory.

  3. At your Web server's root, use the Microsoft Management Console (MMC) to create a virtual directory called WebSettings.

  4. Test the service by using the following URL: https://localhost/WebSettings/WebSettingsService.asmx

To build and run the Web service client by using the command prompt

  1. At the command prompt, navigate to one of the language-specific subdirectories under the Client directory.

  2. Open the code file that defines the WebServiceClientSettings application, and inside the file, locate the code comment about assigning DefaultCredentials to the Web service so that it will run properly.

  3. Before running the code, uncomment the line of code.

    -or-

    Add your own, more secure credentials logic to the code.

  4. Type msbuild.exe followed by the name of the solution or project file.

    For example: msbuild.exe Client.sln

  5. At the command prompt, navigate to the directory that contains a built executable file.

  6. Type the name of the executable file.

    For example: Client.exe

To build and run the Web service client by using Visual Studio

  1. Open Windows Explorer and navigate to one of the language-specific subdirectories under the Client directory.

  2. Double-click the solution file to open the solution in Visual Studio.

  3. Open the code file that defines the WebServiceClientSettings application, and inside the file, locate the code comment about assigning DefaultCredentials to the Web service so that it will run properly.

  4. Before running the code, uncomment the line of code

    -or-

    Add your own, more secure credentials logic to the code.

  5. In Visual Studio, press F5 to compile and run the sample.

See Also

Reference

ApplicationSettingsBase
Binding

Other Resources

Windows Forms Controls Samples