getServerVariable

getServerVariable(var: String): String;

The getServerVariable method of the WebSession class returns the HTTP header information for your World Wide Web request from your Web server.

As the var parameter depends on the Web server version and can change, refer to your Web server documentation for details.

The code fragment in the following example returns the IP address of the current Web session.

currentSession.getServerVariable('REMOTE_ADDR');

Common server environment variables, documented in the IIS documentation under the ServerVariables function, include those listed in the following table.

Variable Returns…
HTTP_ACCEPT_LANGUAGE A string describing the language to use for displaying content
HTTP_USER_AGENT A string describing the browser that sent the request
HTTPS ON (or on) if the request came in through a secure channel (SSL) or it returns OFF (or off) if the request is for a non-secure channel
REMOTE_ADDR IP address of the remote host making the request
SERVER_NAME Host name, DNS alias, or IP address of the server as it would appear in self-referencing URLs
SERVER_PORT Port number to which the request was sent
URL Base portion of the URL

An exception is raised if this method is invoked from a server method.

You can implement your own getServerVariable method (equivalent to this method in the WebSession class) if you are using a JadeInternetTCPIPConnection instance to communicate with the jadehttp library (that is, jadehttp.dll) when your application does not use WebSession functionality.

A name that is longer than 100 characters retrieved by the getServerVariable method call is truncated to 100 characters. This name is used to determine the method to invoke when using non‑wrapped document literal format messages. When the name does not meet the JADE method naming requirements, the method invocation is likely to fail and a SOAP fault to be returned to the Web service consumer.

The following method returns the value of the Internet Server Application Programming Interface (ISAPI) variable (specified by the var parameter) associated with an Internet message that is received.

getServerVariable(var: String): String;
// The request for the ISAPI variable var is built in the bin variable
// The JadeInternetTCPIPConnection instance must exist and be connected
constants
    NULL:       Character = #00.Character;
vars
    bin:        Binary;
    connection: JadeInternetTCPIPConnection;
begin
    if connection <> null and connection.state = Connection.Connected then
        if IsUnicodeSystem then
           bin := ("GSV" & NULL & var.trimBlanks &
                   NULL).Binary._unicodeToAnsi; // unpublished Binary method
        else
           bin := ("GSV" & NULL & var.trimBlanks & NULL).Binary;
        endif;
        connection.writeBinary(bin);
        bin := connection.readBinary(0);
    endif;
    if IsUnicodeSystem then
        return bin.ansiToUnicode.trimBlanks;
    else
        return bin.String.trimBlanks;
    endif;
end;

You can call this method only during the processing of a received Internet message and before the reply is sent. Accessing the method at any other time causes the process to wait indefinitely for the connection read or causes the message exchange process with the jadehttp library to be out of step.