Add the SqlClientWCF Client Project

Provides instructions for adding a client project to the SqlBookWCF solution.

Create a client project

In the real world, you use various client applications to access services via their endpoints. As part of this tutorial, you create a simple.NET COBOL console client application to access the SqlBookWrapper program through the WCF service contract, and query the database.

  1. In the Solution Explorer, right-click the solution; then select Add > New Project.
  2. In the left pane, expand Installed > COBOL; then click Windows Desktop.
  3. In the center pane, select Console Application.
  4. In the Name field, type SqlClientWCF; then click OK.

Add a service reference

Visual Studio provides an easy way to use a WCF service in a client application. The Add Service Reference functionality adds the service to the client project and generates a proxy for the client to use.

  1. In the Solution Explorer, right-click the SqlClientWCF project; then select Add Service Reference.
  2. In the Add Service Reference window, click Discover.
  3. In the Namespace field, replace the default namespace with SqlBookWCF; then click OK.

Edit the client application

You need to program your WCF client so that it uses the exposed operations of your WCF service. In this tutorial, the client passes the stock number as it invokes the Read() operation, and then displays the returned data.

  1. In the Solution Explorer, delete the Program1.cbl template file in the SqlClientWCF project.
  2. Right-click the SqlClientWCF project; then select Add > Existing Item.
  3. On the Add Existing Item dialog box, select All Files (*.*) from the Filename filter drop-down list.
  4. Browse to the %PUBLIC%\Documents\Micro Focus\Visual COBOL\Samples\SQL\ado.net\SqlBookDemoWCF\SqlClientWCF directory.
  5. Select Program1.cbl; then click Add.

Rebuild the solution

  • In the Solution Explorer, right-click the SqlBookWCF solution; then select Rebuild Solution from the context menu.