A NEW TODAY IS DAWNING!

TB0029 - Web-API Visual Basic Example

Number: TB0029

Availability: As of BuildPro 8.00, Web-API users.


Introduction

Using BuildPro Web-API is the most efficient method to communicate with a BuildPro application server. The following code provides a simple example of accessing Web-API from a Visual Basic application. The Web-API Client library is available on all BuildPro platforms (see availability list) and accessible from most programming languages (C, C++, VB etc.).


Detail

While it is possible to access the Web-API directly, this example uses the webapi.dll client. This provides the simplest Visual Basic code and requires no network communication experience. The focus of this example application is to submit a Web-API request from Visual Basic and receive the reply. The example illustrates:

  1. How to initiate the interface to the Web-API Client DLL.
  2. Submit a Request.
  3. Retrieve the Reply.
  4. Handle Errors.
     

How it works

VB interface
 

The Visual Basic application uses the Web-API Client DLL to perform all network communication. By accessing the Web-API Client DLL, the Visual Basic application relies on a few powerful function calls:

  • webApiStartup. Start Web-API Client.
  • webApiCleanup. Shutdown and Clean up.
  • webApiSetRequestPath. Sets the default request path for Request and Reply files (if FileDump).
  • webApiSetFileDump. Tell Web-API write requests and replies to file (for debugging purposes).
  • webApiSetLogFile. Set log file.
  • webApiSetLogLevel. Set log level.
  • webApiStatusRequest. Perform a status request (to test if Web-API Manager is running).
  • webApiMemRequest. Perform a request from memory.
  • webApiMemRequestRaw. Perform a request from memory. Unpack XML.
  • webApiFileRequest Read the specified file and send request to the Manager.
  • webApiFileRequestRaw Read the specified file and send request to the Manager. Unpack XML.
  • webApiFileRequestReply. Read the specified request file, send it to the Manager, and write reply.
  • webApiFileRequestReplyRaw. Read the specified request file, send it to the Manager, and write reply. Unpack XML.
  • webApiWriteLastReply. Retrieve and write last reply.
  • webApiWriteLastFault. Retrieve and write last fault.

To test the demo, download the software below.
 

More Information and Downloads.

Download the Visual Basic EXE and webapi.dll or the complete Visual Basic Project. The sample requires a BuildPro 8.00 or later installation with Web-API Manager running (start it from Services in Windows 2000 or by running the Wepapimanager script on UNIX).

Review the Web-API Client Interface through the header file (unixwebapi.h or win32webapi.h).

The Web-API Client and related files are installed in all BuildPro runtime and developer installations in <install-dir>/lib. If BuildPro is not installed on the PC where you want to run the VB application, copy the Web-API Client DLL (webapi.dll) to the destination machine. The Web-API Client library for UNIX is available on demand (support@todaysystems.com).


What Next?

From here you'll need to add code to package the request details and unpack the reply for further processing. Use an XML parser for easier reading and writing of the Web-API request and reply files.

Note.

The webapiclient executable provides command line access to the Web-API Client Interface. This makes it possible to access the interface from any environment (perl, shell scripts etc.). See webapi.pl for example usage.