With a service description (WSDL), a proxy class can be created with the .NET Framework SDK Wsdl.exe tool. A XML Web service client can then invoke methods of the proxy class, which communicate with SOA Gateway over the network by processing the SOAP messages sent to and from the SOA Gateway server. The proxy class handles the work of mapping parameters to XML elements and then sending the SOAP message over the network.
Wsdl.exe is a Microsoft .NET tool which is used to create proxies for C#, Visual Basic .NET and JScript .NET. In this tutorial, we will be generating C#.
These are the steps required to generate the C# wrapper class using Wsdl.exe and create / run a program listing records from the Adabas demo file "Employees" using the generated proxy class:
From a command prompt, execute Wsdl.exe, specifying the URL / URI of the SOA Gateway DataSource to be exposed, append ?WSDL to instruct theSOA Gateway server to return the WSDL, not data:
If the Wsdl.exe is not found, open the Visual Studio command prompt via the Start Menu. This location depends on what packages are installed, but often resides under "Microsoft Visual C# " or "Microsoft .NET Framework SDK ".
A single source file is generated, its name is <rootElementName>Service.cs, in this case the "root element" within the XSD is "adabasEmployees", thus the name of the proxy class source file adabasEmployeesService.cs
This file contains a proxy class exposing both synchronous and asynchronous methods for each SOAP operation provided by SOA Gateway for the DataSource. For instance, for the list operation, the proxy class has the following methods: list, Beginlist, and Endlist. The list method of the proxy class is used to communicate with SOA Gateway synchronously, but the Beginlist and Endlist methods are used to communicate with the SOA Gateway server asynchronously.
For more information about asynchronous communication with a Web Service please refer to the .NET documentation.
Start MS Visual Studio, create a new project with
-> (or the shortcut Ctrl+Shift+N):Create a C# Console Application, assign a name to it, specify the storage location, click
A skeleton class file has been generated into your project workspace, with the required class definition and an empty Main method
First of all, import the generated proxy into the project, right-click on the project name, select
->select the AdabasEmployeeService.cs proxy, click
The proxy has been added to the project
You now need to add a reference to the .NET System.Web.Services component implementing the SOAP interface. In the project explorer, right click on the project name, select
Scroll down to System.Web.Services, click to select it, click to select it, click
to import the referenceRemove the generated code from the newly added class entirely, use (paste) the code from ASGDemo.cs to create your first test program accessing Adabas data via SOA Gateway.
Build the application. Right-click on the project name in the project explorer, click
Open a command window, change to the project's build-directory Execute the compiled console application, EmployeesList, the output will look as follows:
This sample selects all "Employees" records with a personnel-id of 4000004n, you may want to experiment varying the key data, this is easily done by modifying the properties passed to the generated classes. E.g. try the following to list all records for "Employees" whose names start "SMI", living in cities with names starting "D".
keys.name = "SMI*"; keys.city = "D*;
The output will look like this: