ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage functions / Communication / Web services
  • Overview
  • Importing a web service into a project
  • Import
  • "Project explorer" pane: viewing a web service
  • Description and properties of a web service
  • Updating the description of a web service
  • Properties of a web service modifiable in the editor
  • Using a web service
  • Principle
  • How to set values in the HTTP header of a SOAP web service call?
  • Asynchronous web service call
  • Properties associated with the web service
  • Properties available on the types of variables
  • Advanced operations of the XML stream of the web service
  • Special case: the web service returns a result whose type is not recognized by WINDEV, WEBDEV and WINDEV Mobile
  • Distributing a WINDEV application that uses a web service
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Overview
WINDEV, WEBDEV and WINDEV Mobile allow you to directly import web services into your applications.
A web service is a set of entry points made available to users in order to perform different processes. For example, a remote access service provides the processes used to access the data. Data exchange with a web service is done in XML format, via SOAP (Simple Object Access Protocol) and HTTP.
From the description in WSDL format (Web Services Description Language) of this service, WINDEV, WEBDEV or WINDEV Mobile will automatically generate the WLanguage types and functions corresponding to the programming interface of web service.
To use the web service, simply use the functions generated during the import.
This help page presents:
Java Using a web service in a Java project requires a Java virtual machine (JRE) in version 6 (or 6.1) or later.
Importing a web service into a project

Import

To import a web service:
  1. On the "Project" tab, in the "Project" group, expand "Import" and select "A web service".
    Web service import menu
    The web service import wizard starts.
  2. In the wizard, the presentation screen is displayed. Go to the next step.
  3. Specify the location of the WSDL. This file corresponds to the web service description. It contains the description of each function found in the web service as well as their parameters.
    Address of the WSDL
    Two methods can be used to locate the WSDL:
    • from a URL, HTTP address where the WSDL is found.
      Remarks:
      • You have the ability to specify the username and the password if an authentication is required.
      • The "Proxy" button is used to configure the proxy options if necessary.
    • from an XML file found on the current computer.
  4. Finish the wizard. A message is displayed, indicating that the import is ended.
    Validate import
  5. The Web service is automatically added to the "Project Explorer" pane (in the "Imported Webservices" branch).. It is ready to use.

"Project explorer" pane: viewing a web service

The imported Web service is displayed in the "Project Explorer" pane, "Imported Webservices" folder.:
Web service in the 'Project explorer' pane
The structure includes:
  • the name of the web service.
  • the name of each function.
  • the name of a structure containing either the call parameters, or the return values.
  • the name of each variable in the structure.
Description and properties of a web service

Updating the description of a web service

As a web service evolves (fixes, new versions, etc.), its description may also evolve.
To update the description of a web service in your project:
  1. Select the web service in the "Project explorer" pane.
  2. Select "Update" from the popup menu.
Remark: Web services imported using legacy mode cannot be updated.

Properties of a web service modifiable in the editor

To modify the properties of a web service in the editor:
  1. Select the web service in the "Project explorer" pane.
  2. Select "Description" in the context menu.
  3. The window of properties is displayed. The following properties can be modified in this window:
    • The import address of web service: it is the URL to the WSDL describing the web service.
    • The username and the password used to import the WSDL.
Using a web service

Principle

To use a web service:
  1. Declare 2 variables: a variable used to specify the call parameters and a variable used to retrieve the response.
  2. Initialize each variable of the call structure.
    Important: the order of assignment of variables is used in the XML generated in the SOAP request. It is therefore necessary to assign the variables in the order specified in the documentation of the web service function.
  3. Call the web service function by passing the call variable as parameter and retrieve the response variable in return.
Example:
trackingSearch is trackSearch
trackingSearchRes is resultTrackSearch
trackingSearch.accountNumber = 99999999
trackingSearch.consigneesCountry = "FR"
trackingSearch.consigneesZipCode = "37100"
trackingSearch.sendersRef = "111111"
trackingSearchRes = TrackingServiceWSService.trackSearch(trackingSearch)

IF ErrorOccurred() THEN
	Trace("Echec de l'appel au service Web : " + ErrorInfo(errFullDetails))
ELSE
	Trace("Webservice correctement exécuté")
END
In most cases, the result returned by the web service is in XML format. Therefore, the XML functions must be used to decode the response.

How to set values in the HTTP header of a SOAP web service call?

To set values in the HTTP header of a SOAP web service call:
  1. Declare a wsRequest variable.
  2. Use the HTTPHeader property to set the header values.
  3. Call the web service procedure by specifying the name of the wsRequest variable as the first parameter.
Example:
C is wsRequest
C.HTTPHeader["key"] = "Value"
// Call the web service procedure 
// passing the header and the expected parameters
WebServiceProc(C, param1_WS, param2_WS)
// Displays the request sent
Trace(C.XMLSource)
Remark: On the server side, it is possible to retrieve the header using the WebserviceReadHTTPHeader function. .

Asynchronous web service call

In some cases, the call to a web service may take too long. It may be necessary to make an asynchronous call to the web service, using the following syntax:
APRES <Résultat> = <Procédure d'appel au Webservice> FAIRE
<Code exécuté uniquement lorsque le Webservice aura été exécuté et aura envoyé la réponse>
FIN
<Code exécuté directement après l'appel du Webservice>
Using this syntax, you can prevent the call to the web service from blocking the application. The program continues to run even if the web service has not yet responded.
The previous example becomes:
trackingSearch is trackSearch
trackingSearchRes is resultTrackSearch
trackingSearch.accountNumber = 99999999
trackingSearch.consigneesCountry = "FR"
trackingSearch.consigneesZipCode = "37100"
trackingSearch.sendersRef = "111111"

APRES trackingSearchRes = TrackingServiceWSService.trackSearch(trackingSearch) DO
	IF ErrorOccurred() THEN
		Trace("Echec de l'appel au service Web: " + ErrorInfo(errFullDetails))
	ELSE
		Trace("Webservice correctement exécuté")
	END
END
For more details, see AFTER statement.

Properties associated with the web service

To handle a web service programmatically, simply use its name (as it appears in the "Project explorer" pane).
Remark: You can drag and drop directly from the "Project explorer" pane to the code editor to insert the name of the web service.
The following properties can be modified through programming:
nomType usedEffect
AddressCharacter stringUsed to replace the call address of web service described in the WSDL by another URL. This property is useful if the web service is hosted on different servers.
This property has the following format: "http://server:port/webservice_path".
For a web service generated with WINDEV and deployed on a WEBDEV Application Server, it is the URL of the "awws" file.
Remarks:
  • The modification of this property replaces all the URLs described in the WSDL.
  • If this property corresponds to an empty string (""), the URLs described in the WSDL will be re-used.
WINDEV Authentication
Integer constantUsed to force the HTTP authentication method:
  • auAutomatic (default value): automatic authentication method.
  • auBasic: Basic authentication method.
  • auNegotiate: Negotiate authentication method.
    Linux Caution: This authentication method is not supported by Linux executables.
IgnoreErrorCombination of constantsUsed to ignore the certificate errors. the following constants can be used:
  • httpIgnoreInvalidCertificate: Used to ignore an invalid certificate or a certificate coming from an unknown company.
  • httpIgnoreInvalidCertificateName: Used to ignore the name of the site found in the certificate.
  • httpIgnoreExpiredCertificate: Used to ignore the date of the certificate.
  • httpIgnoreRedirectToHTTP: Used to redirect to a non-secure server.
  • httpIgnoreRedirectToHTTPS: Used to redirect to a secure server.
  • httpIgnoreRevocation: Used to ignore the check in the list of revoked certificates.
Remarks:
  • Java Only the following errors are supported: httpIgnoreExpiredCertificate, httpIgnoreInvalidCertificate, httpIgnoreInvalidCertificateName, httpIgnoreRevocation. The other errors are ignored. For backward compatibility, all the errors are ignored by default.
MethodHTTPInteger constantHTTP method used to call the web service:
  • httpPost (default value): POST method
  • httpPut: PUT method
PasswordCharacter stringPassword used for authentication in the HTTP requests sent to the web service. This name is used only if authentication is required to access the server where the web service is hosted.
PortCharacter stringName of the port defined in the WSDL. It is the port used to communicate with the server that hosts the web service. Contact your network manager or the owner of the web service.
UserCharacter stringUsername used for authentication in the HTTP requests sent to the web service. This name is used only if authentication is required to access the server where the web service is hosted.
With the Negotiate authentication method, the domain must be added to the user depending on the configuration:
monWebservice..Utilisateur = "DOMAINE\Utilisateur"
or
monWebservice..Utilisateur = "Utilisateur@DOMAINE"
VersionHTTPInteger constantHTTP version used by the server:
  • httpVersion2: HTTP version 2.0. If the server does not support this version, an older version is used.
  • httpVersion2Only: Forces HTTP version 2.0: if the server does not support this version, a fatal error is displayed.
  • httpVersion1_1: HTTP version 1.1.
  • httpVersion1_0: HTTP version 1.0.
  • httpVersionDefault: HTTP version 1.0.

Remark:
  • If a username and a password are specified, the authentication of the HTTP requests will be done by using the "Basic" authentication schema, in which the parameters are in readable format in the HTTP request. We recommend that you use HTTPS requests if the authentication is required.
  • If the server that hosts the web service requires a Windows authentication in HTTP, HTTPConfigure must be called before consuming the web service (in order to use Internet Explorer for the HTTP requests).
  • The maximum timeout can be specified with HTTPTimeOut.
Caution: The properties modifiable in the editor and the properties modifiable through programming have no link.

Properties available on the types of variables

The types of variables automatically declared when importing the WSDL propose several properties:
nomType usedEffect
ExistBoolean
  • True if the type of variable exists in the web service response,
  • False otherwise.
OccurrenceentierNumber of elements of this type in the web service response.
A web service can return arrays of variables. The Count property allows you to get the size of the returned array and the [ ] operator allows you to access the elements of the array.
TypeCharacter stringName of the variable type. This property is used when a web service is likely to return responses of different types.
ValueVariantValue of the variable.
Remark: This property is accessed by default when only the variable name is used. For example:
monWebservice.VariableRequete = SAI_Valeur
is equivalent to:
monWebservice.VariableRequete..Value = SAI_Valeur
Java You cannot use a method that manages a shared context.

Advanced operations of the XML stream of the web service

In some cases, you may have to handle the XML data stream exchanged with the web service. For example, some web services require adding headers to their XML stream to enable authentication, or return metadata in the response headers.
The following functions can be used to respond to these particular requests:
SOAPAddAttributeDeclares the additional attributes (not found in the WSDL) on a web service variable automatically generated. It is used in advanced programming when the WSDL returned by the web service does not match the expected type.
SOAPAddHeaderAdds custom headers into a call to a web service.
SOAPGetHeaderReads the information contained in the header of a web service response.
SOAPPrepareBuilds the web service request for a given function and parameters, but does not send it.

Special case: the web service returns a result whose type is not recognized by WINDEV, WEBDEV and WINDEV Mobile

The types of variables available in WINDEV and in a SOAP web service can be different.
Simple types (boolean, integer, etc.) and complex types (datetime, duration, structures, arrays of simple types and array of structures, nested structures, etc.) used in the web service are automatically converted to WLanguage and vice versa, when the service is imported into a project. The Array types are also supported.
The most evolved types (classes, advanced types of WLanguage, etc.) are processed as character strings in the WLanguage code. These strings contain the XML code corresponding to the type of variable returned by the web service and its contents.
Therefore, if a web service returns a result as a class instance, this result will be processed in the procedure as a character string in XML format. Then, you will have to process this character string (in WLanguage) in order to extract the desired information. For more details, see the XML functions.
Remarks:
  • If the web service returns a structure, the names of the members of the return structure are case-sensitive.
  • If you are using a structure as parameter of a web service function and if a DATE member is not assigned, the following error will be displayed: "The 0000-00-00 value does not respect the XSD schema".
Distributing a WINDEV application that uses a web service
To distribute an application that uses a web service, simply include the file that describes the web service (.wsdl file) in the library of the application.
For the application to run the web service, the end-user computer must be connected to the Internet.
Remark: Before distributing an application that uses a web service, it is recommended to check the license and the distribution rights of this service (in case there is a free for the service).
Related Examples:
WD Webservice Client Training (WINDEV): WD Webservice Client
[ + ] This example illustrates the use of WebServices.
It explains how to retrieve, from a WebService, images according to keywords.
This project is the client that connects to the "WD Webservice Server" WebService.
WD Webservice Server Training (WINDEV): WD Webservice Server
[ + ] This example illustrates the use of the WebServices.
It explains how to create a WebService by providing some images according to keywords.
This project is the WebService that is used th the WD Webservice Client project.
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 04/26/2024

Send a report | Local help