The Transaction Server Explorer

The primary interface to MTS is Microsoft Transaction Server Explorer, which provides a way of adding, removing, and managing components under the control of MTS. MTS Explorer (Figure 10-1) is built on the same GUI metaphor as Windows Explorer.

Figure 10-1. MTS Explorer.

In MTS Explorer, you can view components that are located on any machine in the enterprise. Components placed under MTS control reside inside a package, an administrative grouping of components that allows them to exist in the same security context.

Placing an object under MTS control is a relatively simple process. First, you must construct an ActiveX DLL in Visual Basic. At the simplest level, the DLL need not have any special features associated with it. Simply include at least one public method in the class module. For example, the ActiveX DLL named SimpleObject has one class module, Simple, and one method, Process. The following is the complete code for SimpleObject:

Public Function Process() As String     Process = "I got your call!" End Function 

After compiling the DLL, open MTS Explorer. Click the Packages Installed folder, and choose New from the File menu. In the Package wizard (Figure 10-2), click Create An Empty Package to define a new package for the ActiveX DLL. MTS prompts for a name and then creates the new package.

Figure 10-2. The Package wizard.

To install the component, click the new package to open it. Inside the package, click the Components folder and choose New from the File menu. In the Component wizard (Figure 10-3), choose your new component from a list of all registered components on the machine.

Figure 10-3. The Component wizard.

At this point, the component is installed under MTS control. Now whenever the component is called by an ASP page or even another application over DCOM, MTS will intercept the request and process it using a pool of objects created from the SimpleObject ActiveX DLL. The object is available to all enterprise applications that support DCOM.

There is a catch here, however. MTS appears to ASP pages as an out-of-process component, a component that runs in a separate memory space from ASP. Normally, ASP does not allow the use of out-of-process components, but that can be changed using a registry setting. Table D-16 in Appendix D shows the appropriate setting for out-of-process component use in ASP. Be sure to carefully change the setting before attempting to use MTS with ASP.

After the registry setting is changed and the component is installed, you can call the component from a Web page. Use the CreateObject method of the Server object to create an instance of the object and call it. Here is the code:

<% Dim objSimple Dim strReturn Set objSimple = Server.CreateObject("SimpleObject.Simple") strReturn = objSimple.Process %> <%=strReturn%> 

Coding your application with MTS rather than ASP alone has distinct advantages. First, simply by placing your component in MTS, you provide thread pooling automatically. Second, writing ASP code to perform even complex functions now becomes a simple matter of creating an object and calling a method. Finally, any other application can call the same objects that ASP calls, making the enterprise scalable and easier to maintain than it would be without MTS.



Programming Active Server Pages
Programming Active Server Pages (Microsoft Programming Series)
ISBN: 1572317000
EAN: 2147483647
Year: 1996
Pages: 84

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net