Using the QlikView Expressor Datascript Socket Module
Originally published on 07-20-2011 12:18 PM
Another new feature in Expressor 3.3 is the ability to make a socket connection to an external resource. Once you establish this connection, you can send data to the resource and retrieve a response. This functionality is especially useful if you need to utilize some existing resource, for example, an encryption/decryption service, that, for security reasons, cannot be included within your application.
This feature may be used from any of the operators that support scripting and is extremely easy to employ. First, use the following statement to reference the socket module's functionality within your code.
socket = require "socket"
The variable socket now represents a master object that you use to create a client object. Once you have the client object, use its send and receive functions to transmit data to and from the external resource.
As an example, this code from within a transform operator sets up the client object in the intialize function, then communicates with the external resource in order to transform one attribute in the record, and disconnects from the service in the finalize function.