News

WebProcs

The WebProcs' objective is to provide a mechanism to be able to implement a content's server in GeneXus, mainly for the Web through HTTP. When we say content we are referring to any file format ......

When we say content we are referring to any file format. There are two interesting particular cases:

-> XML.
-> Images (E.g.: banners’ server).    

To define a procedure in GeneXus as WebProc we must set the ‘Call Protocol’ property with the ‘http’ value.

Example: Banners’ server.

Let’s suppose that we have a site that for performance or hosting reasons has static pages. We want to include banners in those pages but we want them to vary.
In order to achieve this, we can perform a WebProc that returns an image with a banner at random for example and on the static HTMLs we can indicate the URL where this WebProc is as the address of the banner’s image.
 
Functions to return XML

XmlStart: it allows creating the XML document. You must include the extension. In the case that the document already exist it is overwritten.
XmlBeginElement: it starts a complex element.
XmlValue: It stores a value under the ValueName name.
XmlAtt: it assigns an attribute to the last element or value that was created with the last call to XmlBeginElement (ElementName) or XmlValue (ValueName, ElementValue).
XmlEndElement: It closes the last open element.
XmlEnd: It closes the current document.

Functions for returning files

RespondFile: It sends the specified file to the standard output. The parameter ContentType indicates the type of contents, for example: ‘image/gif’, ’text/html’, etc. If it is omitted you get the type automatically from the extension.
ResponseContentType: Through this function you specify the content’s type (for example: ‘image/gif’, ‘text/html’, etc.) to return in a WebProc. In the parameter you can accept either the complete type or simply the corresponding extension, without the dot.