Perspective and adjust your business and business system (II: COM , ASP)
Small god 2001-10-11
Next, the first step in the three processes will begin, the environment requires two machines, one to do SQL Server, a App and Install IIS. Simulate now the common Windows DNA structure, call BIZ components in the ASP. I will omit the VB's client side, select IE as a Client side, and the only thing to verify is OK.
This article and DOTNET have nothing to do, because there is no DOTNET technology, in order to more real simulation reality, such as complex logic with business requirements, I decided to put SQL Server and components on two machines.
The content I chose the Authi table of the PUB database comes with SQL Server as a prototype. When I look down on some application code and components, I found the entire code is generally divided into two categories: one is the operation of completing a business and business logic, bringing the necessary parameters to the BIZ component, the BIZ component calls other BIZ components or DB The component completes the various operations required, and then returns a simple data type back to the performance layer. For example, a String string (error description), a long type (indicating a kind of water number, what number, or error code, etc.); the other class is a large amount of data returned after a query or some operation, let me be fortunate to be ourselves. It is used to returning these large amounts of data with AdoDB.Recordset, so this category is very unified, usually the return value of the AdoDb.Recordset type. In addition, even Variant is very small, the type of structure defined is almost zero in the return value of the BIZ.
For WebService, the data is unified into XML format, I started to imagine what these adoDB.Recordset will appear in XML? How to use the ADO data in these XML formats? Almost the first reaction is to solve this problem with Microsoft SOAP Toolkit, so the WSDL file generated by SOAP Toolkit is curious, I want to know what the WSDL of this adoDB.Recordset returns. In fact, the results of the later trial are discouraged. However, the problem is earlier, which is the problem of how these custom or data types of data types supported by SOAP is currently centralized on the data type of AdoDb.Recorset. These issues also determine the DB and BIZ components to be generated.
DB components do not have special, BIZ components, I decided to call these DB components directly, there is no logic, in fact Biz may be very complicated, calling many other BIZ or DB components, but often there will be one result. : Success or fail, or return a group of data, that is, two of my collateral. So I started using similar Update, DELETE features:
Public Function Deleteauthor (Byval Au_id As String) AS LONG
To simulate the single data type of the first class returns to SOAP, the real-purpose application may be:
Public Function ChangePaymentType (Byval NTYPEID As Long, Byval Value As Integer) AS Long A commercial logic that modifies user payment methods.
SELECT function
Public Function GetAuthorsbyName (Byval FName As String, Byval Lname AS String) AS AdoDB.Recordset To simulate the return value of the second class back is not the basic data type, the reality may be
Public Function getCustomerInfobYID (Byval NCustomerid As long) AS AdoDb.Recordset A commercial logic of customer data based on customer ID. I list the code used to use the most two functions, especially the two function names, will be largely involved in:
BIZ components: bus_authors.authors, compiled into DLL: bus_authors.dll
Public Function Version () AS STRING
Version = "VB & SOAP VER 1.00"
Objctx.setcomplete
END FUNCTION
Public function getAuthors () as adodb.recordset
ON Error Goto Errhandler
DIM OBJ AS Object
Set obj = creteObject (dbcomname)
Set getAuthors = obj.getauthors ()
Objctx.setcomplete
EXIT_ERR:
EXIT FUNCTION
Errhandler:
Set getAuthors = Nothing
Objctx.setabort
Err.raise Err.Number, SterrSource (MODNAME, "GetAuthors"), Err.Description
Resume EXIT_ERR
END FUNCTION
DB components: db_authors.authors, compiled into DLL: DB_AUTHORS.DLL
Public function getAuthors () as adodb.recordset
ON Error Goto HandleError
DIM RST As Adodb.Recordset
DIM STRSQL AS STRING
SET RST = NewClientrstonlyRead (5)
strsql = "SELECT * from authors"
Rst.Open Strsql, Strconstruct, AdopenStatic, AdlockReadonly, AdcmdText
IF not isrstempty (RST) THEN
Set getAuthors = RST
Else
Set getAuthors = Nothing
END IF
Objctx.setcomplete
Handlexit:
EXIT FUNCTION
HandleError:
Objctx.setabort
Set getAuthors = Nothing
Err.raise Err.Number, SterrSource (MODNAME, "GetAuthors"), Err.Description
Resume Handlexit
END FUNCTION
Version () and getAuthors () are used to simulate two types of return values of the appeal, and the remaining functions include the following functions:
Public Function Echo (Byval Secho As String) AS STRING
Public function getAuthorsbyName (Byval Fname as string) AS adoDb.recordset
Public Function Deleteauthor (Byval Au_id As String) AS LONG
Public Function UpdateAuthorbyAddress (Byval Au_id As String) AS Long This is the addition of parameters, and the above version of Version and GetAuthors have no difference so I only discuss the two functions of Version and GetAuthors, remaining The implementation is only slightly different.
After completing the compilation component, installing the COM of Windows 2000, I built a Application called Authors. Then use the Component Services to fall out of the installation package of Server Application and Application Proxy, and we will use them later. Figure:
Then set up IIS to create a virtual directory Authors Write a simple ASP page to call the bus_authros.authors component's version of the version of the version and the GetAuthors method to generate an HTML output (I have omitted the VB and ASP client test code). Guaranteed http://localhost/authors/testauthors.asp or
Http: //henrysvr/authors/testauthors.asp calls are normal to generate page output in IE.
Testauthors.asp Physical Directory I assume that: c: / inetpub / wwwroot / authors, this directory also involves and stores our WSDL and other documents.
If all the above OK has basically completed the first step, there is an example of a simple Windows DNA architecture such that the following steps can begin, the current architecture may like this:
In addition, the firewall will no longer take into account, I didn't simulate it. The firewall in practical applications is a factor in which the consideration is required.
especially:
The above text and pictures involve other people's privacy and personal rights, such as non-authorized or agree, please do not publish, reprint, adapt, repost, or other forms of communication. All of the above texts and images are only used for internal communication, and do not make any news publishers and commercial purposes.