Proxy Communication Code Examples

In the following example of a method that defines values for JadeTcpIpProxy class properties, note the following points that are referred to in comments within the method.

  1. Setting the browserType property controls how the proxy object behaves. To indicate that the proxy object should not go looking for any configuration information and that all required details are available as property values on the proxy object, set the browser type to BrowserType_None (0).

  2. For the location and type of the proxy server in this example, the proxy server is running on the proxyhost.testing.com, and it is listening for connections on port 8088. In addition, the proxy server is an HTTP-based server so the proxyType property is set to ProxyType_Http (1).

  3. The proxy server requires authentication. If the proxy server supports the Windows Challenge/Response (NTLM) authentication protocol on a Windows PC logged into the domain, the proxy object uses the PC log-in details. If these details fail or if NTLM is not supported, the values in the userName and password properties are used for authentication.

    vars
        tcpip : TcpIpConnection;
        proxy : JadeTcpIpProxy;
    begin
        // Create and setup the proxy object
        create proxy transient;
        // Set the properties we need on the proxy
        // [1] We want total control
        proxy.browserType := JadeTcpIpProxy.BrowserType_None;
        // [2] We know the location and type of the proxy server.
        proxy.host := "proxyhost.testing.com";
        proxy.port := 8088;
        proxy.proxyType := JadeTcpIpProxy.ProxyType_Http;
        // We know it is an HTTP proxy
        // [3] Authentication details are required
        proxy.userName := "Dr. Who";
        proxy.password := "tardis";
        // Set up the TCP/IP-based connection
        create tcpip transient;
        // Normal TCP/IP connection details
        tcpip.name := "server.internet.com";
        tcpip.port := 5432;
        // Add a reference to the proxy object from the TCP/IP object so
        // that the connection is attempted through a proxy server
        tcpip.networkProxy := proxy;
        // Now perform standard TCP/IP logic
        tcpip.open;
        . . .               // do some processing here

In the following example of a method that shows JADE locating and using proxy values for the appropriate type of browser, note the following points that are referred to in comments within the method.

  1. Setting the browserType property controls how the proxy object behaves. Set the browser type to BrowserType_InternetExplorer (1) if the proxy server details have been configured into Internet Explorer or to BrowserType_Netscape (2) if they have been configured into a Mozilla-style Web browser.

  2. As the proxy object needs to know the location and type of the proxy server in this example, we assume that all of the necessary details can be obtained automatically, as follows.

  3. The proxy server requires authentication. In the following example, we assume that the proxy server does not require authentication or that the proxy object can obtain the necessary information from the operating system and pass this behind the scenes to the proxy server without involving us.

    vars
        tcpip : TcpIpConnection;
        proxy : JadeTcpIpProxy;
    begin
        // Create and set up the proxy object
        create proxy transient;
        // Set the properties we need on the proxy
        // [1] We are running on a Windows platform
        proxy.browserType := JadeTcpIpProxy.BrowserType_InternetExplorer;
        // [2] Assume that the location and type of proxy server can
        // be discovered from the registry.
        // [3] Assume that the proxy server does not require authentication
        // or that we are authenticated as part of log on to our PC.
        // Setup the TCP/IP-based connection.
        create tcpip transient;
        // Normal TCP/IP connection details
        tcpip.name := "server.internet.com";
        tcpip.port := 5432;
        // Add a reference to the proxy object from the TCP/IP object so
        // that the connection is attempted through a proxy server.
        tcpip.networkProxy := proxy;
        // Now perform standard TCP/IP logic
        tcpip.open;
        . . .            // do some processing here