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.
- 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
WebService_StockQuotation_getQuote
and the
local variable is svalue, the Web service is called as
follows:LET svalue = WebService_StockQuotation_getQuote( "MyStockSymbol" )
REST
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)