5.2.3.2.3 Diagnostics

If successful, this function must return 0.

If it fails, this function must return -1 as shown in the example:

Example 5-6 Converting Oracle Tuxedo Custom Typed Buffer to SOAP XML Pseudo Code

int mybuffer2xml (void ** xercesDom, CustomerBuffer *a, CustType_Ext * extinfo)
{
       // Use DOM implementation to create the xml payload
       DOMTree = CreateDOMTree( );
       
       if ( error )
              return -1;

       // fetch data from custom typed buffer instance,
       // and add data to DOMTree according to the client side needed
       // XML format

       a->buf ==> DOMTree;

       // allocate xmlbuf buffer via malloc
* xmlbuf = malloc( expected_len(DOMTree) );
       if ( error ) {
              release ( DOMTree );
              return -1;
       }

       // casting the DOMDocument to void * pointer and returned
       DOMTree >> (* xmlbuf);
       if ( error ) {
              release ( DOMTree );
              free ( (* xmlbuf) );
              return -1;
       }

       return 0;
}

WARNING:

The GWWS framework is responsible for releasing the DOMDocument created inside the plug-in function. To avoid double release, you must pay attention to the following Xerces API usage:

If the DOMDocument is constructed from an XML string through XercesDOMParser::parse() API. You must use XercesDOMParser::adoptDocument() to get the pointer of the DOMDocument object. You must not use XercesDOMParser::getDocument() to get the pointer of the DOMDocument object because the DOMDocument object is maintained by the XercesDOMParser object and is released when deleting the XercesDOMParser object if you do not de-couple the DOMDocument from the XercesDOMParser via the XercesDOMParser::getDocument() function.