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. On the Add a new project dialog box, select COBOL from the Languages drop-down list.
  3. Scroll down the list and select Console Application (.NET Framework), and then click Next.
  4. In the Name field, type SqlClientWCF, and 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.