Data Types for Http Handling

Official Content
This documentation is valid for:


Objects: Procedures, TransactionsWeb Panels
Languages: .NET, Java, Visual Basic, Visual FoxPro


In order to handle HTTP protocol GeneXus provides the following data types:

  • HttpClient, which allows you to build a request, send it to a URL and read the results. 
  • HttpResponse and HttpRequest, which allow you to read the request's data and record the response.

Interaction with XML

These objects enable interaction with XMLReader and XMWriter objects. The following methods are used for this:

It is used in any object to read whatever was returned by a request as XML. 

It is used to send an XML in the body of an http request. 

It is used to write an xml which will be returned in the body of the http response. 

It is used to read an xml which comes in the body of the http request. 


This example shows how a GeneXus object calls another one via http, by transferring its parameters in an XML and by receiving the same also in an XML. 

The XML to be sent has the following format: 


The returned XML is the same, with the  ‘A’ and ‘B’ values modified. 

The 'Client' Program will be the following:

&Client,  HttpClient type
&Writer,  XMLWriter type
&Reader, XMLReader type

// Defines the host and the port to which the request will be made  
& = "localhost"
&client.port = 88  

// Adds the XML to the request
&writer.WriteElement("a", &A)
&writer.WriteElement("b", &B)

// Makes the POST to the webproc
&client.execute("POST", "/servlet/awebproc")

// Reads the returned XML and load it in the internal variables.   

&a = val(&reader.value)

&b = val(&reader.value)

The 'Server' Program will be the following WebProc:

&Request,   HttpRequest type
&Response, HttpResponse type
&Writer,      XMLWriter type
&Reader,     XMLReader type

// Reads the XML parameters. 
&a = val(&reader.value)
&b = val(&reader.value)

// Adds one to each value  
&a = &a + 1
&b = &b + 1

// Records the parameters in the response
   &writer.WriteElement("a", &A)
   &writer.WriteElement("b", &B)


See Also