Platform SDK: Web Telephony Engine

Using WTE Configuration and Administration Objects inside Web Applications

As mentioned earlier, you are not limited to using the WTE objects in a stand-alone application. You can create and embed the objects directly in an ordinary HTML application, or you can script the objects in an Active Server Pages (ASP) application.

To create an instance of a COM object in a Web page, you can use the HTML OBJECT tag. Alternatively, if your scripting language provides a native way to create COM objects, you can create an object instance using script.

The following example illustrates using the OBJECT tag to create and embed a WTEVendorDataSets collection containing a single WTEVendorDataSet object in a Web page. Note that the CLASSID is the UUID that is part of the object's interface definition. To find the UUID for any WTE object, see the mswtecom.idl file, which ships in the Platform SDK.

<OBJECT 
  ID = ACMETelephonyProductsVendorData
  CLASSID = "UUID:B83E8318-336C-11D3-8657-0090272F9EEB"
  PARAM NAME = "Add" VALUE = "ACMEDatabaseName">
</OBJECT>

The syntax for creating a COM object in an ASP page is similar to that used in the embedding example above. You must first create an instance of that object by using the OBJECT tag as shown in the following example.

Note that the WTE object must run on the server in order to be used by ASP but, by default, the OBJECT tag creates an instance of the object on the client. Setting the RUNAT attribute to SERVER causes the object to be created on the server.

<OBJECT 
RUNAT=SERVER 
ID = ACMETelephonyProductsVendorData
  CLASSID = "UUID:B83E8318-336C-11D3-8657-0090272F9EEB"
  PARAM NAME = "Add" VALUE = "ACMEDatabaseName">
</OBJECT>

You can also create an instance of a COM object on an ASP page by calling the CreateObject method of the ASP Server object. Using Server.CreateObject is slower than creating the object using an OBJECT tag, but you do not have to provide a CLASSID. The Server object itself is exposed by ASP and does not need to be created. The following VBScript example shows how to add a new WTEVendorDataSet object, called ACMEIncomingLine to the existing collection of ACMETelephonyProductsVendorData objects, by calling Server.CreateObject.

<% 
  Set ACMEIncomingLine = Server.CreateObject("ACMETelephonyProductsVendorData.Add") 
%>

ASP allows you to work with many different types of scripting engines, each of which supports a different scripting language. VBScript and JScript scripting engines are provided with ASP, but you can also plug in scripting engines developed by other companies to support languages such as PerlScript, PScript, Python, and others.

If you do not explicitly set the scripting language for an ASP page, the default is VBScript. To specify a scripting language other than VBScript, include a line such as the following at the top of each ASP page.

<%@ LANGUAGE=PerlScript %>

Because calling the CreateObject method takes more time than using the OBJECT tag, you should use the OBJECT tag in applications where performance is critical.

Once you have created an instance of the COM object, you can access its methods and properties in scripts. The following VBScript example sets the Value property for the vendor data object created in the preceding example:

<% ACMEIncomingLine.Value = 18005551212 %>

For more information about using COM objects in Web applications, including examples in other scripting languages, see Scripting with COM Objects.