Configure and Test the WCF Service Library

Walks you through the process of configuring a service endpoint, and testing the service via the WCF Test Client application.

Configure the service endpoint

This is the default endpoint that exposes metadata details about your service through the IMetaData Exchange contract.

  1. In the Solution Explorer, right-click the app.config file in the SqlBookWCF project; then select Edit WCF Configuration from the context menu.
  2. In the left pane of the Microsoft Service Configuration Editor, expand SqlBookWCF.Service1; then click Host.
  3. In the right pane under Base Addresses, observe that the base address is local, as specified by the http://localhost portion of the address.
  4. In the left pane, expand Endpoints; then click the first (Empty Name) instance listed below.
  5. In the right pane, click the Contract field; then click its browse button.
  6. Browse to the \bin\Debug project subdirectory.
  7. Double-click SqlBookWCF.dll.
  8. Select the SqlBookWCF.IsqlBook contract; then click Open.
  9. Click File > Save; then close the Editor.

Test the Service

Visual Studio provides a built-in WCF Service Host application and a WCF Test Client application that enable you to test your service without having to create a client application.

  1. SqlBookWCF should already be set as your startup project as evidenced by its bold appearance in the Solution Explorer; however, if it does not appear in bold, right-click the SqlBookWCF project; then and select Set as StartUp Project from the context menu.
  2. From the main menu, click DEBUG > Start Without Debugging.

    This starts the service and invokes the WCF Test Client window. The left pane shows the endpoint for your service and the operations that are exposed.

  3. In the left pane, double-click the Read() operation.

    This populates the right pane with operation details, and enables you to test the operation.

  4. In the Request pane, change the value for stockNumber to 1111; then click Invoke.
    Note: If a Security Warning appears, check In the future, do not show this message.; then click OK.

    This populates the Response pane with the data associated with stock number 1111.

  5. Test the operation again, substituting alternative stock numbers. Valid values are 1111, 2222, and 3333.
  6. Close the WCF Test Client window.