Business Reference Architecture: Enterprise's Consumers Chapter 6: Solution Guide Microsoft Corporation 2001 Abstract: This chapter provides the solution to implement component, including: Advanced graphic representation of the application, About PASP file and XSLisapi filtering How to play a role, a description of each primary component category in a consolidateDretail.com application. Introduction Reference Architecture Application Contains many custom ASP files and code components. The sections of this chapter will detail the source code for these files. Figure 6-1 visually clearly shows the various components of the solution and its interrelationship. When reading the rest of this guide and viewing the source code, the map can be used as a basic reference. Figure 6-1: Reference Architecture Application Components As you can see from this figure, users use the browser (here INTERNET Explorer 5) to access the application. The ASP file in the website is implemented as a pre-processed ASP (PASP script), and the programmable object provided by Commerce Server 2000 (such as ProductCatalog, AuthManager, UserProfile, and ORDERGROUP) sends data to the Commerce Server site database in SQL Server 2000 and Retrieve data from this site database. Business processes such as order or see the shopping basket content are achieved through the Commerce Server pipeline. Pipe call Custom COM queuing components to process email messaging functions. The output of each web page is represented by XML and then intercepts by the XSLisapi 2.1 filter, and the XSLisApi 2.1 filter applies the corresponding XSL style table to the content and renders the content as HTML. The next section of this chapter will explain how the PASP file and the XSLisAPI filter work, and a brief example is provided as a reference. This chapter will then introduce how each primary component category is implemented in a consolidatedretail.com application. Our discussion uses logical reasoning ways, first introduces Web services, then introduce the Commerce Server object, followed by discussing pipe components. PASP files and XSLISAPI Filters Active Server Page (ASP) are often used to generate representations logic for web solutions. In the consolidateDretail.com site, use their approach. At this site, most ASP files are implemented as pre-processed ASPs (ie, PASP files). The PASP file writes an XML to the response object, which is intercepted and processed by the XSLisapi filter. The script in the PASP file is used to call business logic in the Commerce Server 2000 object; the XSLisapi filter processes the representation. The XSLISAPI filter performs syntax analysis from the XML output generated from the PASP file and checks the XML-STYLESHEET ...?> Processing instructions. If the processing explains the Server-Config property that references the XML configuration file, the XSLisapi filter reads the configuration file to determine which XSL style table should be applied to the XML output generated from the PASP file. The XML configuration file contains information about which style table should be applied to a particular client type, as shown in the following code example: XML Version = "1.0"?>
device>
device>
device>
Server-Styles-Config>
IIS can identify the client program as long as you check the Hypertext Transfer Protocol (HTTP) request header that is sent with the page request. IIS uses the entries of the browscap.ini file in the Winnt / System32 / IneTsrv folder, you can identify many normal browsers. The XSLisapi application provides additional entries for devices for WAP phones in files called BrowsCap-add.ini, and users should copy and append them to the browscap.ini file. Simply illustrative The following simple example shows how to use the XSLisAPI filter to present XML output generated by the PASP file. Note that this example is intended to help you understand the functionality of the XSLisapi filter. It does not meake any actual pages in the consolidatedretail.com site. Assume that the user uses Internet Explorer 5 to request a page name myproducts.pasp. The system will explain the scripts in the file, then return to the following XML: XML Version = "1.0"> by the following response object
Xml-stylesheet type = "text / xsl"
Server-config = "productconfig.xml"
HREF = "csproducts.xsl"?>
productList>
Now, the XSLisAPI filter will perform syntax analysis of the XML and read the XML-Stylesheet processing instructions, which contains the following three properties:
TYPE: Refers to the type of style sheet to be applied (here XSL). Server-config: Refers to an XML configuration file that defines a style sheet to be used for a specific client. HREF: When the corresponding style sheet is not listed in the Server-Config file, the client will download and apply the default style sheet. Then, the XSLisapi filter reads the specified server-config file (ProductConfig.xml), which contains the following entries:
device> Since IIS has identified the client browser based on the request header to Internet Explorer 5.0, the XSLISAPI application is now applied to XML retrieved from MyProducts.PASP. Assume that the Products-IE5.xsl style table contains the following XSL code: XML Version = "1.0"?>
Version = "2.0">
Product Catalog Title>
Td> tr>
TABLE>
Body>
Html>
xsl: template>
xsl: stylesheet>
The style sheet will be applied to XML data obtained from MyProducts.Pasp to generate the following HTML, which will be sent to the browser:
Product Catalog Title>
Small Machine TD> TR>
Wrench td> tr>
TABLE>
Body>
Html>
Obviously, in a practical e-commerce solution such as consolidateDretail.com, XML generated by the PASP file and XSL style sheet for rendering the XML is much more complicated than that of the simple example. However, the principle is the same. Website Documents introduce some ASPs and PASP pages and the corresponding XSL files, which are often used in the user interface of the consolidatedretail.com retail site. As mentioned earlier, many ASP scripts used by the application are implemented as the PASP script, which submits the XML output to the XSLisapi filter. Some conventional ASP scripts are also used as non-display scripts to accept posts from other pages. Each PASP page has a related -config.xml file, the XSLisapi filter uses this file to determine the corresponding style sheet to be used for a particular client type. In this implementation, only the -ie5.xsl file is provided to use the HTML form compatible with Microsoft Internet Explorer 5.5. To make the output can be used for other browsers or devices, you can create additional XSL files. Initialization page and include file consolidatedretail.com Site Use the following initialization script and include files:
Global.asa: Global.asa is a web application initialization script that defines the actions to take when a key event occurs during the survival of the web application. /include/site_const.asp: This file defines a lot of constants, all pages on the site contain this file. /include/common.asp: This file defines some functions that are used to present data in the form of XML tags. All PASP pages on the site use this file to generate XMLs that will be transmitted to the XSLisAPI filter. /include/profile.asp: This file contains all functions that do the following: Verify the user's identity, register or log out of the user, retrieve or update the user's personal profile. /include/basket.asp: This file provides users to create and maintain shopping baskets (ie, accumulate orders during browsing the product). /include/ui_layout-ie5.xsl: The XSL style sheet provides a representation logic for rendering the standard layout form of each page in the site. All page dedicated XSL files contain this style sheet to ensure that the site presents uniform appearance and behavior. Directory Browse page consolidatedRetail.com Retail Site Use the following with directory-related pages: Default.asp: This page redirects the user to the home page (INDEX.PASP). Since DEFAULT.ASP is the traditional start page name of the ASP application, it places it here to redirect all requests to Default.asp to the real start page of the application. Index.PASP: Index.PASP is the default start page for the application. This page is displayed when you only enter the site name without attaching the path information. Several other pages are also redirected to this page when the task is completed or an error occurs. Category.PASP: This page enters XML for a specific page, in which user can view the product and subcategories of the given product directory specific category. Product.PASP: This page enters the specific page to generate XML content, in this particular page, you can display details on a single product and all variants in the product directory. SearchResults.PASP: When the user enters a search criteria in the Product Search box, the page receives the input content, then searches for the product that matches the keyword, and returns the list of matched products to the user. User Authentication and Profile Management Page ConsolidatedRetail.com Retail Site Use the following user authentication and management scripts:
Registration.pasp: Use this page, users can register at the site. Login.PASP: Using this page, the registered user can log in to the site. ForgotPasswd.PASP: Through this page, users can request a site to send your password to yourself with email. Acct.Pasp: This page displays the account details of the currently logged in user. UserProfile.Pasp: On this page, users can edit their own configuration files. AddressBook.PASP: On this page, the user can view and update the address book, which contains the delivery address and payment address. Order Management Page ConsolidatedRetail.com Retail Site Use the following order management page:
ORDERHISTORY.PASP: This page retrieves and displays the order history of the current user, allowing users to view all the items you purchased at this site. ORDERHISTORYDETAIL.PASP: This page displays details of specific orders in the user's order history. Basket.PASP: This page displays the current user's shopping basket content, specifically, is the product contained in the ORDERGROUP object related to the user's current session. ORDERSUMMARY.PASP: Although the display result of the page is largely different from the display result of the Basket.PASP page, the script of this page and the XML content generated by the script are very similar to the Basket.PASP page. Shipping.PASP: This page will be called when the user clicks the "Checkout" link of the shopping basket page or click the "Checkout" link at the top of any page. The user can specify the shipping address of the order at this page. Shippingmethod.PASP: On this page, users can choose the shipping method of the order. MultiShipping.PASP: On this page, users can specify different delivery addresses for multiple projects in the same order. THANKYOU.PASP: On this page, complete the order processing of the Commerce Server section of this application by running a series of Commerce pipeline processes. Another important feature of the Commerce Server object This solution is to use the Commerce Server 2000 programmable object for business processing. Any customer program that recognizes COM (such as ASP scripts) can use these objects to retrieve data in the site database or perform tasks that verify the user identity. The use of these objects will be discussed in detail when introducing the functionality provided in Chapter 7. Here, just briefly describe several critical Commerce Server objects used in the consolidatedretail.com application. Utilities and configuration object e-commerce sites are a fairly complex application that requires various information and functions. To simplify the development of e-commerce solutions, Commerce Server 2000 provides a lot of objects that can be used to manage site configuration information and the general features available throughout the site. In fact, many objects used in the Commerce Server solution are Dictionary objects or SimpleList objects. These are common objects that can be used to maintain a collection of names / values. For example, in a consolidateDretail.com application, Dictionary objects are used to store the collection of pipes used in the site. For more information on Dictionary and SIMPLIST objects, please refer to the Commerce Server 2000 documentation. ConsolidatedRetail.com Applications use the following utilities and configuration objects throughout the site:
AppConfig: This is the Commerce Server application configuration object that provides a way to retrieve site configuration. It includes an Options dictionary object that can be used to store various configuration options for storing the site. In the consolidateDretail.com site, the Options dictionary is used to store the data source connection string and other configuration information. DataFunctions: This is an object that defines the data format, store information about site area settings, currency, and other issues related to data. This object also provides a method of processing data type unique tasks, such as deleting spaces in a string or converts data from one type to another. GenID: This is a utility object for generating a global unique identifier (GUID). These identifiers are useful when they need to provide a unique ID to identify the specified item. AppFramework: This is a utility object for simplifying HTML form processing. MessageManager: This object is used to store multi-language error messages for pipeline components. CacheManager: This object is used to manage the data cache of the site. If you are cache data such as directory, delivery methods, user profiles, and significantly improve system performance. Dictionaryxmltransforms: This object uses a specific XDR architecture to implement the Dictionary objects and the mutual conversion between the XML. For more information on AppConfig, DataFunctions, Genid, AppFramework, MessageManager, CacheManager, and DictionaryxmlTransForms objects, please refer to the Commerce Server 2000 documentation. Directory objects can retrieve product information from a directory related to the site, which is one of the common tasks that must be completed in the e-commerce site. Microsoft® Commerce Server 2000 supports multiple directorys in a single site. You can organize the directory into a hierarchical structure with nested categories that can define products on any level of the directory (including roots). Alternatively, you can associate any category or product with other categories or products anywhere in the hierarchical structure. For example, you can associate the "Software" category The product with Windows® 2000 Server is associated with the product named "Book" category. This will easily create links to related products or categories to create cross-selling opportunities. Figure 6-2 shows the directory structure supported by Commerce Server 2000. Figure 6-2: Commerce Server 2000 Directory Structure Using Commerce Server Business Desk, you can create a directory from steps or import directory from an XML or CSV file. For more information on how to use the Business Desk Management Directory, please refer to the Commerce Server 2000 documentation. Another directory support feature in Commerce Server is that you can create a "directory set". The directory set refers to a collection of one or more directories, assigns these directory to a particular user class based on attributes in the user profile. For example, you can create a directory set, which contains some price-discount directories to provide discounts for users who participate in the faithful customer plan. For users that are not assigned directory sets, the Commerce Server site contains the default directory set provided for anonymous users and the default directory set provided by users through authentication. Program access to directory data can be provided by the following Commerce Server automation objects:
CatalogManager: This object represents the entire directory management system. CatalogSets: You can access the directory set defined in the site through this object. ProductCatalog: This object represents a specific directory. Category: This object represents the category in the directory. Product: This object represents the product. The above object provides a method of browsing the entire directory hierarchical structure of the site. Many methods and properties provided by these objects return ADO record sets, which contain directory, category, or product data. For any directory data, you must initialize the connection to the site data source to access them. Typically, to complete this, you must call the Initialize method of the CatalogManager object, which will transfer the ADO connection string or site name of the site database as a parameter. For more information on CatalogManager, CatalogSets, ProductCatalog, Category, and Product objects, please refer to the Commerce Server 2000 documentation. User Management Object Commerce Server provides several objects for managing user information and status when the user is interactive with the site. These objects include: AuthManager: This object is used to process features related to security, allowing users to authenticate and log in, providing the way to identify a particular user. PROFILESERVICE: This object is used to connect to the data source, where stores configuration file information related to the registered user of the site. ProfileObject: This object is used to encapsulate configuration file data for a particular user and can be used to set or retrieve the following values: Name, Phone Number, Email Address, or any other user properties that need to be tracked. For more information on AuthManager, ProfileService, and ProfileObject objects, please refer to the Commerce Server 2000 documentation. Shopping basket object When the user finds the product you need to purchase, it is allowed to put the product into a shopping cart or a shopping basket is the usual move of the website. In fact, the shopping basket concept is just a metaphor of software objects, which represents the item collection selected by the user during access. Commerce Server 2000 provides the following objects for shopping basket management.
ORDERGroup: This object represents a shopping basket. ORDERFORM: This object represents a collection of items in the shopping basket. The ORDERFORM object is implemented as a Dictionary object, which contains the overall information of the order, and the SimpleList object contains a project Dictionary object that represents a single project in the shopping basket. Addresses SimpleList objects are used to store the collection of address Dictionary objects, representing delivery addresses and payments related to orders. For more information on ORDERGROUP and ORDERFORM objects, please refer to the Commerce Server 2000 documentation. Pipeline Commerce Server 2000 solutions typically use pipes to handle business. The pipe is composed of a series of COM components that will operate the business objects such as ORDERFORM. The components in the pipe and the order of calling these components are specified in the pipeline configuration file (* .pcf). You can treat the pipe as a production line, where each component performs a specific task, then transfer the service object to the next component. Consolidatedretail.com uses three pipes named pagbasket.pcf, total.pcf, and final.pcf. For the reference to their references in the application-level Mscspipelines dictionary variable, Pagbasket, Pagtotal, and PAGFINAL. The specific process of these pipes will be introduced when the functionality of the site will be discussed later. The components in the pipeline assembly pipe are COM components that implement the iPipeLineComponent interface. This interface provides an Execute method that can transmit a dictionary object to the method. The business process can be implemented in the Execute method of the ORDERFORM, which is transmitted to each component in the pipe. Commerce Server provides a large number of pipeline components that can be used for e-commerce sites. These objects are used to apply discounts to orders, collect taxes, arrange delivery, and more. In addition, you can create custom pipe components to perform specific tasks. The consolidatedretail.com site contains two custom piping components: