I have a need to base64 encode outbound messages for a particular interface. How would I best accomplish this? Ive been told that Cloverleaf allows you to leverage a built in base 64 encoder.
The script I am working with is below. I have to encode the hl7 message, not the soapware wrapper. Guidance is much appreciated.
######################################################################
# Name: tps_batch_bos_imm
# Purpose: <Add Batch Segs>
# UPoC type: tps
# Args: tps keyedlist containing the following keys:
# MODE run mode ("start", "run", "time" or "shutdown")
# MSGID message handle
# CONTEXT tps caller context
# ARGS user-supplied arguments:
# <describe user-supplied args here>
#
# Returns: tps disposition list:
# <describe dispositions used here>
#
# Notes: 1: Add seg BHS and BTS
#
# History: <date> <name> <comments>
#
proc tps_batch_bos_imm { args } {
global HciConnName ;# Name of thread
keylget args MODE mode ;# Fetch mode
set ctx "" ; keylget args CONTEXT ctx ;# Fetch tps caller context
set uargs {} ; keylget args ARGS uargs ;# Fetch user-supplied args
set debug 0 ; ;# Fetch user argument DEBUG and
catch {keylget uargs DEBUG debug} ;# assume uargs is a keyed list
set module "tpsChangeHL7/$HciConnName/$ctx" ;# Use this before every echo/puts,
;# it describes where the text came from
set dispList {} ;# Nothing to return
switch -exact -- $mode {
start {
# Perform special init functions
# N.B.: there may or may not be a MSGID key in args
if { $debug } {
puts stdout "$module: Starting in debug mode..."
}
}
run {
# 'run' mode always has a MSGID; fetch and process it
keylget args MSGID mh
lappend dispList "CONTINUE $mh"
set msg [msgget $mh]
set seglist [split $msg r]
#echo seglist $seglist
set bhs {<soap:Envelope xmlns:soap="
http://www.w3.org/2003/05/soap-envelope"xmlns:urn="urn:cdc:iisb:2011"><wsse:Security xmlns:wsse="
http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><wsse:UsernameToken wsu:Id="UsernameToken-100" xmlns:wsu="
http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">ccghlsevenqa<wsse:Password ENGINE="
http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">blablablawonderlandInsert Base-64 encoded message here</urn:hl7Message>{BHS|^~&|}}
set bts {BTS|1|]]></urn:hl7Message></urn:submitSingleMessage></soapenv:Body></soapenv:Envelope>}
set newlist [linsert $seglist 0 $bhs] ;# replace with the updated segments
## set newlist [linsert $seglist end $bts r]
lappend newlist $bts r
## set newlist
## llength $newlist
#echo newList $newlist
set newMsg [join $newlist r] ;# Put msg back together with cr
regsub -all -- {rr} $newMsg r newMsg ;# Remove double c/r
msgset $mh $newMsg ;# set mh
}
time {
# Timer-based processing
# N.B.: there may or may not be a MSGID key in args
}
shutdown {
# Doing some clean-up work
}
default {
error "Unknown mode '$mode' in $module"
}
}
return $dispList
}