Skip to content

Class: cXmlHttpTransfer

Properties | Events | Methods | Index of Classes

Provides an easy mechanism for sending and receiving XML documents via Http.

Hierarchy

cObject > InetTransfer > cBaseHTTPTransfer > cHttpTransfer > cXmlHttpTransfer

Show full hierarchy and direct subclasses

Library: Common Class Library

Package: cXmlHttpTransfer.pkg

Description

This class provides an easy mechanism for sending and receiving XML documents via Http. XML documents can be sent and retrieved as XML objects. XML data (actually any data) can also be sent using strings or data pointers but the main purpose of this class is to allow the sending and receiving of XML document wrapped in DOM objects. In addition, properties exist that allow you to determine if and how your posted and received data will be translated.

Sample

Here is an example of GETting XML data. It will return the received data as an XML object.

Function GetMyData returns Handle
    handle hoHttp
    handle hoRcvdXml

    // Create xmlHttp transfer object.
    Get Create U_cXmlHttpTransfer to hoHttp
    // we choose not to translate the incoming data
    Set peTranslateReceived of hoHttp to xtNoTranslate
    // post xml document and receive returned Xml document
    Get HttpGetXmlNode of hoHttp "dataaccess.com" ;
        "MyApplication/XmlService.asp" to hoRcvdXml
    // transfer object no longer needed
    Send Destroy of hoHttp
    // return rcvd XML document, or 0 if error
    Function_Return hoRcvdXml // this is newly created, and must be destroyed by the calling method
End_Function

Sample

Here is an example of posting and receiving XML data. The XML document to be posted is sent to this function as a DOM object. It will return the received data as an XML object.

Function PostMyData handle hoSentXml returns Handle
    handle hoHttp
    handle hoRcvdXml

    // create xmlHttp transfer object.
    Get Create U_cXmlHttpTransfer to hoHttp
    // post xml document and receive returned Xml document
    Get HttpPostXmlNode of hoHttp "dataaccess.com" ;
        "MyApplication/XmlService.asp" hoSentXml to hoRcvdXml
    // transfer object no longer needed
    Send Destroy of hoHttp
    // return rcvd XML document, or 0 if error
    Function_Return hoRcvdXml // this is newly created, and must be destroyed by the calling method
End_Function

This class allows you to transfer and receive data that is larger than the string size limitations imposed by DataFlex. It does this by augmenting OnDataReceived and using heap functions and address data types to manipulate the data. You may wish to study the class source code to see how this is done so you can create other cHttpTransfer subclasses that allow you to transfer large amounts of data. Also note that the event, OnDataReceived, is not a public event in this class - you should not change it.