Previous Topic Next topic Print topic


Building Service-Oriented Applications with WCF and COBOL

Windows Communication Foundation (WCF) is part of Microsoft's .NET Framework that enables you to build service-oriented applications. WCF services consist of a number of operations which you can expose to client applications through different endpoints.

With Visual COBOL you can create and access WCF COBOL services for versions of the .NET Framework version 3.0 or greater. Note: This replaces the ASMX Web reference clients which is the only option when you target .NET Framework v. 2.0.

Restriction: The WCF project types are not available in the Visual Studio Shell but adding a service reference for client applications is supported.

The following is a brief overview of the process of creating and consuming a WCF service:

  1. Create a new project, a WCF Service Library.
  2. Specify the service contract.

    A contract is an interface that includes the operations that a service endpoint exposes to the client applications.

    • You create the contract as an interface and specify the System.ServiceModel.ServiceContract() attribute on it.
    • The service operations to expose to client applications are the methods in the interface. You need to set the System.ServiceModel.OperationContract() attribute on these methods.

    Note: WCF Services use mostly the members that are part of the System.ServiceModel and System.Runtime.Serialization namespaces.

  3. Create the WCF service.

    You can define this as a COBOL class that implements the interface and the methods that represent the service operations.

  4. Configure the service.

    You specify the details for accessing the WCF service (the host and the endpoint details) in the App.config file in your project. You can use the WCF configuration editor to edit the App.config file - right-click the file and select Edit WCF Configuration.

  5. Host and run the service.

    You need to specify the service endpoints through which the service functionality is exposed, and enable metadata exchange for the service. The general details, or so called ABC, of an endpoint are: the address of the service, its binding and the service contract which is exposed. The WCF Service Library template has preconfigured endpoint and metadata exchange details which you might need to modify.

    Visual Studio provides a WCF Host Application and a WCF Test Client to enable you to host and test your services without a client application.

  6. Create a WCF client application.

    This is the application that accesses and consumes your service. The client connects to the WCF service through one of its endpoints and uses the service operations that are exposed.

    You can create the client application as a new project in your WCF solution and add a service reference to the WCF service project. From the context menu for the project invoke the Add Service Reference dialog and use it to discover and select the services in the solution.

  7. Configure the client to access the service through one of its endpoints.

    You specify the endpoint details for accessing the WCF service (the service address , the binding, the service name and contract) in an app.config file for the project for the client application.

  8. Use the client to access the service operations that are exposed.

    When the WCF service project is part of the solution that contains the client application, the service is usually hosted automatically when you start debugging. You can configure this in the project properties for the WCF service project.

For more, check Tutorial: Creating and Accessing WCF COBOL Services and the WCF Book Service and Client demonstration in the Samples.

Previous Topic Next topic Print topic