NonStop SOAP User's Manual
Customizing the SOAP Server
NonStop SOAP User’s Manual—520501-012
8-43
Examples
Example 8-6. Sample Code Accessing Headers - I
long SoapUEHandler_Generic::pre_process (ServiceEnv *env,                                                                 
       SoapFault *sf)
{
  gSoapTrace.log ("Entered SoapUEHandler_Generic::pre_process\n");
  UESoapHeaderManager * reqMgr = env -> getReqHeaderMgr( );
  if (reqMgr == NULL || 
  reqMgr -> getHeaderCount ( ) <= 0){
  gSoapTrace.log ("No interesting SOAP Headers found. Leaving
     pre_process.");
  return 0;
  }
  UESoapHeader * hdrPtr = reqMgr -> getFirstHeader ( ); 
  int count = 0;
  //For the above SOAP Request message, the while loop will be entered only
  //once for the custom SOAP Header represented by <security:LogonHdr>
  while (hdrPtr != NULL){
   count++;
  //This will print out 
  //  1
  gSoapTrace.log ("Header # %d\n", count);
  gSoapTrace.log (" ****************************\n");
  //This will print out 
  //  security:LogonHdr
  gSoapTrace.log ( hdrPtr -> getHeaderName( ).c_str( ) );
  gSoapTrace.log (" ****************************\n");
  //This will print out the attributes as follows:
  //  xmlns:security -->
  //  http://mycompany.security.com/header/logon
  //  Encoded --> yes
  DOM_NamedNodeMap attributes = hdrPtr -> getAttributes( );
  for(int i=0; i < attributes.getLength(); i++){
   gSoapTrace.log(attributes.item(i).getNodeName());
   gSoapTrace.log(" --> ");
   gSoapTrace.log(attributes.item(i).getNodeValue());
  }
   //This will print out the following://
   // <user>T#A#%(**PQ{</user>// 
   // <password>%@@#$**!@#!#**</password>
   // This data can be parsed by the user if further processing
   // is needed
   gsoapTrace.log ( hdrPtr -> getValue( ).getNodeValue( ));
   gSoapTrace.log (" ****************************\n");
   hdrPtr = reqMgr -> getNextHeader ( );
 }     










