AddSoapHeaderNode - cWebService

Adds a SOAP header node to a method's SOAP response.

Type: Procedure

Parameters: Handle hoNode

hoNodeThe handle to an XML element node to be added as a SOAP Header.

Procedure AddSoapHeaderNode Handle hoNode

Call: Send AddSoapHeaderNode hoNode


AddSoapHeaderNode is used to add SOAP headers to a method's SOAP response. This is a low level mechanism. It is expected that a developer using this method understands SOAP headers and understands how to work with XML objects.

The handle passed to this method must be a handle to an XML element object (cXMLDomElement). If an element node is not passed, an error will be generated.

Note that you do need to pass the actual SOAP

node, as the service does this for you. Instead, you pass the element nodes that are the children of the header node. Each time you call AddSoapHeaderNode, you add a new node to the SOAP header.

   <Transaction xmlns="some-URI">5</Transaction>

The above SOAP header could be created as follows:

Get Create U_cXmlDomDocument to hoXml
Get CreateDocumentElementNS of hoXml "some-URI" "Transaction" to hoRoot
Set psText of hoRoot to "5"
Send AddSoapHeaderNode hoRoot
Send Destroy of hoXml

SOAP request headers may be processed by using the SoapHeaderRequestNode method.

The following example demonstrates how to get all requested SOAP headers and return them as response SOAP headers.

Get SoapHeaderRequestNode to hoXml  // get the SOAP request header
If (hoXml) Begin
    Get DocumentElement of hoXML to hoRoot // this will be <header>
    // Get all SOAP request child nodes
    Get FirstChild of hoRoot to hoNode
    While hoNode
        Send AddSoapHeaderNode hoNode  // Add to response header
        Get NextNode of hoNode to hoNode
    Send Destroy of hoXml

See Also