|
||
The CAS XML interface uses standardized XML formatting and HTTP communications to provide access to NET SatisFAXtion. The CAS API, with it's assortment of function and data tags, and the rules governing the placement of tags in taglists, is nearly identical regardless of whether an application is written to the CAS ActiveX interface or XML interface. To a client application these interfaces are very different, but to NET SatisFAXtion taglists are treated the same regardless of their origin. To create and send taglists, applications can use XML and XMLHTTP APIs provided by Microsoft, or from other development tools. To simplify development, FaxBack created the CAS XML Script Library that uses Microsoft's APIs to create taglists and connect to NET SatisFAXtion. With the script library, it is possible to write an application that uses XML and XMLHTTP to communicate with NET SatisFAXtion without installing CAS ActiveX controls on the client computer. However, CAS ActiveX controls can be installed if desired, and applications can be written that use both the CAS ActiveX and XML interfaces. When you are ready to send your first
fax, make sure that you have examined the CAS Samples
on this website. The CAS Samples provide live demonstrations and example
source code for the most commonly used CAS functions. See the
CAS Tags page for a listing of available CAS function and data tags. Working with Taglists
<CAS> Very little code is required to send a properly formed taglist to NET SatisFAXtion using Microsoft's XML and XMLHTTP APIs. The following JavaScript example is a complete CAS XML processor (simplified for brevity) that loads a taglist from a file, sends the taglist to NET SatisFAXtion, and then saves the response taglist to a file. In the example below, the function taglist in the input.xml file could contain everything necessary to send a fax including a cover page and attachments. |
Simplified CAS XML Processor: | |
var XML = new ActiveXObject("Microsoft.XMLDOM"); var XMLHTTP = new ActiveXObject("Microsoft.XMLHTTP"); if (XML.load("input.xml")) { XMLHTTP.open("POST", "http://casdev.faxback.com/cgi-bin/casxml.asp", false); XMLHTTP.send(XML); XMLHTTP.ResponseXML.save("output.xml"); } else { alert(XML.parseError.reason+"\r"+XML.parseError.srcText); } |
Taglists are constructed by creating an empty taglist with the xmlTlNew function, and then adding tags to that list with the xmlTlAddTag function. The only case when tag order is important involves the first tag in a taglist, which is typically a function tag. Tags are added to a taglist sequentially; there is no capability to insert a tag at a specific location.
Tl = xmlTlNew(); Sections are created by calling the xmlTlCreateSection function. Tags are then added to the new section with the same xmlTlAddTag function. The section is closed by calling the xmlTlCloseSection function. Once a section is closed, no more tags can be added to it, but more tags and sections can be added to the root of the taglist.
xmlTlCreateSection(Tl,"RECEIVER_ADDRESS","555-123-4567"); Taglists are sent to NET SatisFAXtion by calling the xmlTlSend function. The xmlTlSend function uses HTTP to post the XML to a CAS/XML proxy according to a supplied URL. The return value from xmlTlSend is an XMLDOM object containing the response XML from NET SatisFAXtion or from the script library itself, in the case of a communications error.
responseXML = xmlTlSend(Tl, "\\\\CASDEV\\NETSATISFAXTION", "NETSATISFAXTION", 2, "http://casdev.faxback.com/cgi-bin/casxml.asp"); To work with response taglists from the fax server, the xmlTlGetTag function is used to search for tags and retrieve tag data in the response XML. This function does little more than call the XMLDOM selectSingleNode method to locate a tag (element) within the XML and then return the text from that tag. Tags at the root level of a taglist are retrieved by passing a tag name to the xmlTlGetTag function, for example: stat = xmlTlGetTag(responseXML,"STATUS_NUM") Tags located in sections within the taglist are retrieved by passing the xmlTlGetTag function an XPath that combines the section name and the tag name, for example, to read the connection seconds from the first MESSAGE_HANDLE section in a taglist the following XPath would be used: secs = xmlTlGetTag(responseXML,"MESSAGE_HANDLE[0]/CONNECTION_SECONDS") All standard XPath rules apply, and you are encouraged to use any of the functions available in the XMLDOM to search and retrieve information from the response XML. |
CAS clients exchange taglists with NET SatisFAXtion through a CAS/XML proxy
that must be installed on a
web (HTTP) server. The CAS/XML proxy converts XML function taglists sent
via HTTP from a client, into native CAS taglists that are sent to NET SatisFAXtion over LAN protocols or direct-memory.
The
proxy reverses the process to send a response taglist from NET SatisFAXtion back to the
client.
The CAS/XML proxy relies on the host web server's HTTP (or HTTPS) communications services to perform most of the work of interacting with the client. The URL of the proxy is what links the client to NET SatisFAXtion. Given the proxy URL, a client can access multiple NET SatisFAXtion servers through a single CAS/XML proxy. Starting with version 7.0, NET SatisFAXtion includes an integrated HTTP server that has a built-in CAS/XML proxy. The URL of the proxy, when sending CAS requests over a local LAN, is typically http://{server name}/casxml.api. Alternatively, a CAS/XML proxy can be installed on Microsoft's IIS web server, by downloading the CAS XML Tools from this website. The following diagrams illustrate the different types of connections that CAS XML clients can make:
To execute a CAS function, clients use HTTP to "post" an XML taglist to a CAS/XML proxy, and then process the reply taglist either synchronously or asynchronously. This differs from the CAS ActiveX interface, where the client is required to logon to a NET SatisFAXtion connection router as well as open and close network sessions while sending taglists. The CAS XML client must provide the DOMAIN_NAME, REMOTE_LOGON_NAME and PROTOCOL that the proxy will use when connecting to NET SatisFAXtion. For this reason, all CAS XML taglists must include a root <CAS> element, where the immediate child elements provide the proxy with the necessary logon information. The taglist itself is contained within a <TAGLIST> element, which is also a child element immediately under the root <CAS> element. For example:
<CAS> The CAS XML Script Library provides functions that simplify XML taglist construction and automatically ensure that the XML is formatted properly. It is, however, beneficial to understand the basic layout of XML taglists, for situations where taglists are created by other means, such as concatenating text strings. Working with Files
<CAS> Unlike the CAS ActiveX interface, where the CURRENT_FILESPEC and DESTINATION_FILESPEC tags are used to reference local files, with the CAS XML interface the CONTENT_DATA tag is used instead to contain the file within the XML. For example, when retrieving an inbound fax from the server with GET_FILE_FUNCTION, the content of the file is included in the response XML. The application must extract the file content from the CONTENT_DATA tag, which is encoded in base64. The following taglist is a response from NET SatisFAXtion after using GET_FILE_FUNCTION to retrieve a message attachment:
<CAS> The FaxBackX ActiveX control, which is included with the CAS ActiveX controls, includes base64 conversion support, including methods that convert directly to and from files. Because of this and other features, the FaxBackX control is recommended whenever it is possible to install ActiveX controls on the client computer. As an alternative, the CAS XML Script Library provides script functions to perform base64 conversions without using the FaxBackX control. However, the script library functions require the application to handle all file I/O if the source or destination data for the conversion resides in a file. |
Example base64 encoding using FaxBackX: | |
var FBX = new ActiveXObject("FaxBackX.soap"); function SendFaxFile( File ) { var Tl = xmlTlNew(); xmlTlAddTag(Tl,"SEND_MESSAGE",null); xmlTlAddTag(Tl,"REGISTERED_NAME","User1"); xmlTlAddTag(Tl,"REGISTERED_PASSWORD",""); xmlTlAddTag(Tl,"TRANSFER_TYPE",0); // 1= EMAIL, 0=FAX xmlTlCreateSection(Tl,"RECEIVER_ADDRESS","555-123-4567"); xmlTlAddTag(Tl,"RECEIVER_NAME","MyRecipient"); xmlTlCloseSection(Tl); xmlTlCreateSection(Tl,"CONTENT_PART",3); // Attachment xmlTlAddTag(Tl,"CONTENT_TYPE",0); xmlTlAddTag(Tl,"CONTENT_DATA",FBX.base64_encode_from_file(File)); xmlTlCloseSection(Tl); var responseXML = xmlTlSend(Tl, "\\\\FAX\\NETSAT", "NETSAT", 2, "http://netsat/casxml.asp"); return(xmlTlGetTag(responseXML,"STATUS_NUM")); } |
Example base64 decoding using FaxBackX: | |
var FBX = new ActiveXObject("FaxBackX.soap"); function GetMessageFile( MsgHandle, MsgFileName, DestinationFile ) { var Tl = xmlTlNew(); xmlTlAddTag(Tl,"GET_FILE_FUNCTION",null); xmlTlAddTag(Tl,"REGISTERED_NAME",UserName); xmlTlAddTag(Tl,"REGISTERED_PASSWORD",UserPassword); xmlTlAddTag(Tl,"MESSAGE_HANDLE",MsgHandle); xmlTlAddTag(Tl,"CURRENT_FILESPEC",MsgFileName); var responseXML = xmlTlSend(Tl, "\\\\FAX\\NETSAT", "NETSAT", 2, "http://netsat/casxml.asp"); if (xmlTlGetTag(responseXML,"STATUS_NUM") == 0) { // Extract file from XML and convert from base64 var FileContent = xmlTlGetTag(responseXML,"CONTENT_DATA"); FBX.base64_decode_to_file(FileContent,DestinationFile); } } |
The CAS XML Script Library provides functions to create and send CAS XML
taglists to NET SatisFAXtion. The library is included with the CAS XML
Tools (available from the Downloads section
of this website) and includes JavaScript and
VBScript versions. This is the same code used by the CAS Samples on this website.
The script library can be used from script in ASP pages running on IIS, HTML files loaded by Internet Explorer, and stand-alone script files. For example, the following line, referencing the VBScript version of the script library, can be added to an ASP page to access the script library functions: <script language="VBScript" runat=server src="CASXMLLib.vbs"></script> Select a link below for a detailed description of a CAS XML Script Library function. |
||
Returns | Method | Parameters |
xmlTl | xmlTlNew | None |
VOID | xmlTlAddTag | xmlTl, Tag, Data |
VOID | xmlTlCreateSection | xmlTl, Tag, Data |
VOID | xmlTlCloseSection | xmlTl |
xmlDoc | xmlTlSend | xmlTl, Domain, Server, Protocol, ProxyURL |
BSTR | xmlTlGetTag | xmlDoc, TagPath |
Utility | ||
BSTR | CASEncryptOnce | Password |
BSTR | GetXMLDump | xmlDoc |
BSTR | Base64Encode | InputData |
BSTR | Base64Decode | InputData |
The FaxBackX ActiveX control assists applications that use the CAS XML
interface. It's main value is in providing base64
encoding and decoding functions, but if an application can obtain this
functionality from another source then neither FaxBackX nor any other FaxBack
ActiveX control is required on the client computer.
To use FaxBackX, an application must first create a reference (or pointer) to the FaxBackX interface, and then save that reference so that it can be used globally throughout the application. Although a single, global FaxBackX reference should suffice, there is no harm in creating multiple references to the ActiveX interface within the same application. The following examples demonstrate accessing the FaxBackX interface from VBScript, JavaScript, and C++. Although each language has a unique method of creating the ActiveX interface, all languages use the interface similarly. |
|
|||
Function AccessFaxBackX() Dim FBX, encoded Set FBX = CreateObject("FaxBackX.soap") encoded = FBX.base64_encode("Encode this string") End Function |
|||
function AccessFaxBackX() { var FBX, encoded; FBX = new ActiveXObject("FaxBackX.soap"); encoded = FBX.base64_encode("Encode this string"); } |
|||
#include <windows.h> #import <faxbackx.dll> using namespace FAXBACKXLib; void AccessFaxBackX() { Isoap *FBX; CLSID class_id; CoInitialize(NULL); if (CLSIDFromProgID(L"FaxBackX.soap",&class_id) == S_OK) { if (CoCreateInstance(class_id, NULL, CLSCTX_INPROC_SERVER, IID_IUnknown, (void **)&FBX) == S_OK) { _bstr_t encoded = FBX->base64_encode("Encode this string"); FBX->Release(); } } CoUninitialize(); } |
FaxBackX Methods
Select a link below for a detailed description of a FaxBackX method. |
||
Returns | Method | Parameters |
BSTR | base64_decode | InputData |
BOOL | base64_decode_to_file | InputData, FileName |
BSTR | base64_encode | InputData |
BSTR | base64_encode_from_file | FileName |
BSTR | encrypt | Password |
VOID | sleep | Milliseconds |