Establish Browser-Server Structure Applications with PowerBuilder

zhaozj2021-02-16  45

Establish Browser-Server Structure Applications with PowerBuilder6.0

1998.10.20 Sun Bin Wang Dong, Calculation Center, Xinjiang University of Categories

【Abstract】 This article mainly discusses the Internet solution and work mode of the BrowerBuilder 6.0 implementation of the Browser / Server structure, discusses the data flow of several important modules that implement this method, and finally give an example.

PowerBuilder 6.0 Realizing the Prerequisites for the "Web Browser - Database Server" scheme is to build a distributed application system. Bringing the PowerBuilder6.0 application to the Internet structure, that is, put the PowerBuilder 6.0 client application to the web server, when the browser client issues a service request to the web server, the web server automatically calls the PowerBuilder application software system, thereby achieving each Internet structure function of business software.

First, form a module structure of the Browser / Server structure.

The various Internet-based applications developed by PowerBuilder6. 0 are implemented using PowerBuilder6.0, which is implemented using PowerBuilder6.0 and PowerScripts programming technology, which is equivalent to writing server applications in a distributed application environment. For example, PowerScripts language environment, data window technology, etc. Its production process and working principle are:

1. Establish and configure the web server. O'Reilly Based on WindowsNT 3.51, PowerBuilder, 32-bit multi-threaded personal web server Website 1.1 version of WINDOWSNT 3.51 and Win 95/98. The web server provides a complete web service creation, management environment, and security mechanism.

2. Create an executable (Web.PB) on the web server. The main function of the web.pb (pbcgi60.exe) is to call the preset handler in the PowerBuilder application server, including analysis of user functions in the user object, feedback HTML control flow and generating interpretation plug programs.

Web.PB is used to develop a web application based basic part, which is itself a gateway application on the web. The tool provides access from the web server to the PowerBuilder application server, allowing users to perform nearly complete manipulation of databases over Web under Internet and intranet. At the same time, through web.pb, dynamically create an HTML document is also possible. The web.pb program is a bridge connected to the web server and the PowerBuilder application server. Build a web application using Web.PB has the following advantages:

a. Support CGI, ISAPI, NSAPI, MSAPI and other gateway program interfaces.

b. Support for reference to data windows in PowerBuilder.

c. Easy to transfer the previously writerbuilder application to the web environment.

d. Easy to create an HTML file embedded in the PowerBuilder application, the application server will dynamically generate the HTML syntax according to user requirements, and release fully dynamic information.

e. Support database connections. The database that PowerBuilder can be connected can be accessed by the browser user, so that the Web service is integrated with the database service through Powerbuilder 6.0.

3. Establish a PowerBuilder application server. The PowerBuilder application server is primarily some class library programs for activating the PowerBuilder6.0 business application. When creating the PowerBuilder application server shown in the image, you must reference the PowerBuilder6.0 web class library. Five custom class user objects are defined in the class library, encapsulate functions, structures, and instances required to create HTML syntax and transaction management. A variety of entities can be used to create an HTML syntax, manage the status of the client browser connection. Powerbuilder 6.0 Application Server is equivalent to a client application in a distributed application to issue a call request to the PowerBuilder6.0 business app. The implementation method is: After the PowerBuilder6.0 application server monitors the request of Web.PB, start the PowerBuilder application server that has predefined business handler in the PowerBuilder application server. For example, when a user uses a web browser (IE or Netscape) to browse the page, the web server can automatically activate the web.pb application by embedding the element embedded in the HTML page. The event web server first calls the WEB.PB class program for PowerBuilder6.0. As the client application in the PowerBuilder distributed application, establish a connection to the PowerBuilder 6.0 application server, then call the various business features defined in the PowerBuilder6.0 application server, That is, user functions encapsulated in user custom objects, including database access and file processing and other data processing functions.

4. Establish a PowerBuilder business application. In a user-defined object, create a user-defined function. Functional requirements are based on the needs of the browser-end users, and the processing results are used in the HTML page format, feedback to the web.pb program, often used in personnel management, financial management, information data processing and system management.

Powerbuilder business applications have inserts (PLUG_INs) and embedded HTML files. The use of Plug-Ins (inserts) is divided into two kinds of Window Plug-Ins and DataWindow Plug-Ins.

The way the Window Plug-INS inserts to prepare the business program is to embed and display the window object of the Child type in PowerBuilder6.0 on the HTML page. You can place the data window (dataWindow), TreeView, TAB page, etc. A colorful control type, enriching the expression of the HTML page. When the client browsses the page with the browser, the web server uninstalls the PSR file or PBD file to the customer. The client browser receives the PSR file and the PBD file, embed the Child window object in the web page, if embedding the window object, The functions defined on the window can also be used in the browser environment. If the function of the database manipulation is defined on the window, the browser client can directly connect the manipulation database. Plug-Ins play a role in embed PowerBuilder6.0 objects into the page, and the data window has a rich display style, users are more welcome to "Powerbuilder Child Class Data Window" data performance forms on the browser.

Write the use of Window ActiveX Similar to Window Plug-Ins, which is used to embed and display a window object in the PowerBuilder in the HTML page. This component can interact with VBScripts and JavaScripts in HTML.

The method of simply embedding the HTML file is the popular programming trend, that is, if you don't have to insert products, the client only needs to install a regular web browser, you can realize the real "thin" Browser / Client / Server structure system.

In summary, the PowerBuilder6.0 application server returns the execution result of the service handler in the HTML format to the web server. The web server releases HTML to the user, and the client browser receives the result on the browser. Second, a simple Internet application example

1. Use the web server to configure the web.pb program. Web server has a lot of types, here in this Websuit1.1 server, other types of web servers are similar. The web.pb program includes files such as PBCGI60.EXE, PSISA60.DLL, PBNSL60.DLL, PBNS260.DLL, WebBAgent.dll, and Pbweb.ini. Note: Set the mapping directory / scripts / for C: / Website / CGI-SHL; copy the above web.pb file to / scripts / directory; copy the PBWeb.ini file to the system directory of Windows NT or Windows 95; Add the following in the webpb.ini file:

[PB60]

Driver = Winsock

Application = 10082

Location = 202.201.208.6

2. On the PowerBuilder 6.0 development platform, select the Internet option to create a PowerBuilder6. 0 Application Server. The technical point is to establish an Internet app, join the webpb.pbl library file and make a script for starting the server, and the content is:

Transport.myTransport

MyTransport = CREATE TRANSPORT

MyTransport = "Winsock"

My transport.location = "202.201.208.6"

//Powerbuilder6.0 application server listening address

MyTransport.Application = "10082"

//Service port number

MyTransport.listen ()

// Start the listening service

Return

3 Set the service database server and Sybase SQL Anywhere Local Library Wedpb.db connection. Among them, the business data is stored in the database server, such as SQL6.5, Sybase 11, Informix 6.0, IngRes, and DB2 and other types of databases; local library webpb.db, only the control information of the PowerBuilder 6.0 application server is stored.

4. Create a user object and write a handling script for the user object. For example: Create a user object UR and prepare the following script for the constructor event:

MyTransaction = CREATE TRENSACTION

MyTransaction.dbms = 'odbc "

MyTransaction.dbparm = "ConnectString = 'DSN = WebPB'"

CONNECT Using MyTransaction;

IF myTransaction.sqlcode <> 0 THEN

MessageBox ("MyTransaction. Error =" String (MyTransaction. &

SQL_DBCODE), myTransaction.sqlerrtext)

END IF

SQLCA.DBMS = "MSS (MSOFT) SQL Server 6.5"

Sqlca.database = "xyw"

SQLCA.USERID = "sa"

Sqlca.servername = "server" sqlca.logid = "sa"

CONNECT Using SQLCA;

IF SQLCA.SQLCODE <> 0 THEN

MessageBox ("Sqlca. Error =" string (Sqlca.sql_dbcode), Sqlca.sqlerrtext)

END IF

Write the following script for the DESTRUctor event:

Disconnect Using MyTransaction

Disconnect Using Sqlca

The purpose is: When web.pb calls the PowerBuilder6.0 server, the user object automatically establishes the connection with the database, and disconnects after the call is completed.

5. Write a user-defined function, and data processing of various business work is done by this class function. For example, on the user object UR, create a function fp () of a query function, its content is:

String return_html

Long ii

DataStore Data_FP

Data_fp = CREATE DATASTORE

Data_fp.dataObject = "dw_fp"

// dw_fp is a query data window that has been done

Data_fp.settransobject (MyTransaction)

II = DATE_FP.RETRIEVE ()

/ / Retrieved record number deposits II

IF II> = 1 THEN

Return_html = data_fp.Object.dataWindow.Data.htmltable

Else

Return_html = "Data without retrieving the condition"

END IF

Return Return_HTML

6, start the server, then start the PowerBuilder6.0 application server; browse the page containing the following HTML syntax in the customer browser:

Query page instance

query start

This PowerBuilder6.0 data window DW_FP can be displayed on the customer browser interface by clicking the hypercraft link "query", completes a simple "thin" Browser / Server application.

转载请注明原文地址:https://www.9cbs.com/read-26068.html

New Post(0)