Skip to content

HttpPostXmlString - cXmlHttpTransfer

Posts and receives XML data as string

Type: Function
Return Data Type: String

Parameters

Parameter Type Description
sHost String The URL host (e.g. DataAccess.com - Note: DO NOT include the "HTTP://")
sFilePath String The file path and any data passed in a query string (e.g. MyXMlSite/XmlSrvc.asp?ID=A)
sXml String An XML string. It is not required that this data be valid XML. As long as the server can process what you send it, the string may contain whatever you wish

Syntax

Function HttpPostXmlString String sHost String sFilePath String sXml Returns String

Call Example

Get HttpPostXmlString sHost sFilePath sXml to StringVariable

Description

The HttpPostXmlString function posts and receives XML data as strings. The data is received and returned as a DataFlex string and is therefore subject to string length limitations. If an error occurs in the transfer or if there is no resulting data, an empty string is returned. The returned data does not have to be a valid XML document.

Both posted and received data is translated as needed, based on the values of peTranslateSent and peTranslateReceived.

Sample

handle hoHttp hoXml
string sSentXml sRcvdXml
boolean bOk

Move "<customer><c1>test</c1><c1>test2</c1><c1>test3</c1></customer>" to sSentXML

// Create xmlHttp transfer object.
// Post xml document and receive returned Xml document

Get Create U_cXmlHttpTransfer to hoHttp

Get HttpPostXmlString of hoHttp "dataaccess.com" ;
     "MyApplication/XmlService.asp" sSentXml to sRcvdXml

Send Destroy of hoHttp

If (sRcvdXml="") ;
    send Stop-Box "No document returned" "Error"
else begin
    send Info_Box sRcvdXml

    Get Create U_cXmlDomDocument to hoXml

    get LoadXml of hoXml sRcvdXml to bOk

    if (bOk=True) ;
        send DoWhateverYouWantWithXmlDocument hoXml

    Send Destroy of hoXml
end

See Also

Info_Box

Return Value

The data is received and returned as a DataFlex string and is therefore subject to string length limitations. If an error occurs in the transfer or if there is no resulting data, an empty string is returned.