English|Português|Español
UserPasswordLogin

HOME
SESSIONS
INFO
Imagen6279E

From GeneXus Olimar version: easier use of Web Services

GeneXus 7.5 already provided access to Web Services. With the Olimar version, however, GeneXus will provide total support for web services, by incorporating the WSDL Inspector, which will enable transparent consumption of Web Services.

Scope
Languages: Java, C/SQL, .NET, Visual FoxPro, Visual Basic
Interfaces: Win, Web
 
Introduction
The WSDL Inspector is used for defining, from the WSDL  (Web Services Description Language Inspector) of a web service, the types of data needed in GeneXus for consuming the web service in a transparent way without worrying about the protocols involved in the process or their definition.


Description
The WSDL is a file that describes the web service and provides all the necessary information in order to use it. GeneXus provides a tool called the WSDL Inspector used for defining in the knowledge base, from the WSDL of a web service, everything that is necessary for using the web service methods in a transparent way.


To have access to the WSDL Inspector you have to execute the Tools/WSDL Inspector options.

 
In "Web Service URL" you must type the path to the WSDL.
It can be referenced through the http protocol (e.g. http://api.google.com/GoogleSearch.wsdl ) or file (e.g. file:C:\Servicios\AmazonWebServices.wsdl).
Once the WSDL's path has been typed, press the "Inspect" button, with which, in case there is no error, the information of the different methods provided by the web service will be displayed, together with the types of data needed in order to make use of them.

For importing the information that is necessary within the knowledge base in order to consume a web service, press the "Add Reference" button.

In the previous image, we show the information of a simple web service that has a single method called BabelFish, which receives two entering, Character-type parameters and retrieves another Character-type parameter. There is no definition for any type of complex data in it.

 

The following example shows another case in which a web service has more than one method and there are complex data:


Add reference
As we mentioned earlier, by pressing the "Add Reference" button, the types of data necessary for consuming the web service in a transparent way are generated in the knowledge base. This means that what is actually generated is a type of data that identifies the web service, and in case it uses complex types of data, a certain type of data is generated for each one of them.

This way, a variable may be defined, which is assigned the type of data defined for the web service, and by using methods from this variable, the different methods offered by the web service may be called.


Data structures
Web Services usually retrieve values in data structures. For instance, they retrieve a "Client", a structure that has "Code" and "Name", which is also another structure, which has "FirstName", "SecondName", etc.
In GeneXus you will be able to define variables of "Client" data-type and modify/access their "members" through the following syntax: Client.Name.FirstName. 
So far, the definition of data structures is only available through the WSDL Inspector. In the future, an editor will be included in order to define the structures that developers deem necessary.


Web service method invocation
Let us go back to our first image and show with a simple case how to use a web service. In this case, by pressing the 'Add Reference' button, the "net_xmethods_www_sd_BabelFishService.BabelFishService" type is added to the data types handled by GeneXus.

(Note that the name assigned to the type of data is preceded by the namespace that identifies the web service; this way, GeneXus guarantees that there will not be two types of data with the same name for different web services).

This way, a variable may be defined, which is assigned that particular type of data; we will call it "ws".
Then, we will be able to make an invocation, by using the "ws" variable, to any of the methods provided by the web service (only one in this case) in the following way: &result = &ws.BabelFish(&traslationmode, &source)
where &result, &traslationmode and &source are character-type variables.
That is all! This way, you could call a web service in a simple way without having to worry about the protocols involved in the process and their definition; you just had to give the location of your WSDL and GeneXus was in charge of hiding the complexity and defining a type of data to represent the web service. 

 

Example
In the GXOpen there is a KB as an example, in which three web services are consumed: GXChart (graph server), Babelfish (text translator) and GetJoke (provides jokes grouped under categories).
You can get it at http://www.gxopen.com/main/hproject.aspx?176

Interesting links:
WSDL Inspector
WSDL
Web services

Related
GeneXus Olimar version: conditional orders and filters
From the GeneXus Olimar version: Client Side Validation
A profitable online business uses GeneXus latest technology
New TEAMS Version with GeneXus 8.0