Introduction to Web services

Web services are a standard way of communicating between applications over an intranet or Internet.

Web services can be invoked via the HyperText Transfer Protocol (HTTP), by requests for services, and information is returned in either JSON documents or XML documents. It does not matter if the platform that runs the Web Service is different to the platform that receives the JSON or XML document.

Genero Web Services supports Web services implemented by the Simple Object Access Protocol (SOAP) and Representational State Transfer (REST) architecture, which are defined standards for communicating with Web services. A Web service defines how to communicate between two entities:
  • A server that exposes services
  • A client that consumes services

Server usage example

A server exposes, for example, a "StockQuotation" service that responds to an operation "getQuote". For the "getQuote" operation, the input message is a stock symbol as a string, and the output message is a stock value as a decimal number.

The "getQuote" operation is a function written in Genero BDL, and it is published on the server. This function retrieves the stock value for the stock symbol passed in, and returns it.

Client usage example

The Web service client application calls the function as if it were a local function. It passes the stock symbol to the function, and stores the returned value in a variable.

SOAP

If the Web service operation is named WebService_StockQuotation_getQuote and the local variable is svalue, the Web service is called as follows:
LET svalue = WebService_StockQuotation_getQuote( "MyStockSymbol" )

REST

The Web service operation is requested using the URI with the required parameter that matches the function defined in the "StockQuotation" Web service server side. Therefore, quotes becomes the resource name part of the URI included in our example code. req is defined as an object of the com.HttpRequest class.
LET req = com.HttpRequest.Create("http://localhost:8090/ws/r/quotes?symbol=FJS)