Platform SDK: Web Telephony Engine

Retrieving Address Information

This section describes how to retrieve the TAPI object and the TAPI Addresses collection from a WTE application.

The TAPI object is the application's entry point to TAPI 3.0. This object represents all telephony resources to which the local computer has access, allowing an application to enumerate all local and remote addresses.

The TAPI Addresses collection contains all of the currently available Address objects. Each Address object represents an entity that can make or receive calls. An application uses this object to get and set information concerning the address, such as whether it has caller ID support. Capabilities can be retrieved from an Address object, such as media and terminal support. An application can wait for a call on an Address object, or can create an outgoing call object from an Address object.

For more information about the TAPI object and Addresses collection, see Microsoft Telephony Overview.

To retrieve the TAPI object and Addresses collection

  1. Retrieve an instance of the DispatchMapper object.
  2. Use the DispatchMapper.QueryDispatchInterface method to retrieve an instance of the CallInfo object. When calling QueryDispatchInterface, you must specify the GUID of the CallInfo object and a reference to the ITBasicCallControl object.
  3. Use the CallInfo.Address property to retrieve an instance of the Address object.
  4. Use the Address.TAPIObject property to get an instance of the TAPI object.
  5. Use the TAPI.Addresses property to access the Addresses collection.

The following example shows how to use VBScript to get the TAPI object and TAPI Addresses collection:

IIDCallInfo = "{350F85D1-1227-11D3-83D4-00C04FB6809F}"
Set myDispMapper = CreateObject("DispatchMapper.DispatchMapper.1")
Set myBasicCallControl = window.external.ITBasicCallControl
Set myCallInfo = myDispMapper.QueryDispatchInterface(IIDCallInfo, myBasicCallControl)
Set myAddress = myCallInfo.Address
Set myTAPI = myAddress.TAPIObject
Set myAllAddresses = myTAPI.Addresses
For Each pITAddress in myAllAddresses
    stringOutput = "AdressName " & pITAddress.AddressName & 
      "Dial. Addr " & pITAddress.DialableAddress
    MsgBox stringOutput
    window.external.LogCustomField.DefaultValue = stringOutput
    window.external.log()
    window.external.LogCustomField.DefaultValue = ""
Next

The following example shows how to use JScript to get the TAPI object and TAPI Addresses collection:

IIDCallInfo = "{350F85D1-1227-11D3-83D4-00C04FB6809F}";
IIDTapi = "{B1EFC382-9355-11d0-835C-00AA003CCABD}";
myDispMapper = new ActiveXObject("DispatchMapper.DispatchMapper.1");
myBasicCallControl = window.external.ITBasicCallControl;
myCallInfo = myDispMapper.QueryDispatchInterface(IIDCallInfo, myBasicCallControl);
myAddress = myCallInfo.Address;
myTAPI = myAddress.TAPIObject;
myAllAddresses = myTAPI.Addresses;
for(i = 1; i <= myAllAddresses.Count; i++) {
    pITAddress = myAllAddresses.Item(i);
    stringOutput = "AdressName " + pITAddress.AddressName + 
      "Dial. Addr " + pITAddress.DialableAddress;
    window.external.LogCustomField.DefaultValue = stringOutput;
    window.external.log();
    window.external.LogCustomField.DefaultValue = "";
}

The scripting code in the previous examples is useful in the following scenario: Suppose an application receives a call that has come through a PBX to a voice board. Using a table, the application determines that the voice board received the call on port 3, and that the call came from extension 105 on the PBX. Using the code described in the previous examples, the application creates an object for the address number 105 on the PBX. The application also obtains the called ID of the current call and stores the ID in a global session variable.

At this point the application can perform several telephony operations. For example, a call center or T1-based application can use the PBX rather than the voice board to transfer the call to an agent, if necessary. After the call is disconnected, the application can use its post-call page to keep track of the call as it moves through the PBX from one agent to another.

The application calls the Abandon method only when the call finally leaves the PBX. For more information, see Disconnecting a Call.