proc IbEnvelopeIn

The IbEnvelopIn proc, along with IbClientEnvelopeOut is a template for taking in messages that are properly formed SOAP envelopes. This is used within the sample sites that take advantage of the XML capabilities (XML formats) and translations, with the help of the XSD/WSDL tools. IbServerEnvelopeOut, as a group are considered a better approach to the SOAP/XML messaging solution than the IbOutXML/IbInXML pair because of better overall XML handling.

The hard-coded string and regular expression techniques that are used in that pair can be used with XML. When you do this, difficulties could happen when namespaces and sophisticated features are involved.

######################################################################
# Name:                 IbEnvelopeIn
# Purpose:              The message coming into this proc should be an ibmime
#                            structured message from IB.  This proc will unwrap the
#                            soap envelope inside and replace the message's contents
#                            with this soap envelope.  This can be used regardless
#                            of whether IB is acting as the client or server.
# UPoC type:           tps
# Args:                   tps keyedlist containing these keys:
#                            MODE     run mode ("start", "run" or "time")
#                            MSGID    message handle
#                            ARGS      user-supplied arguments:
#                                             <describe user-supplied args here>
#
# Returns:              tps disposition list:
#                             <describe dispositions used here>
#

proc IbEnvelopeIn { args } {
     keylget args MODE mode          ;# Fetch mode

     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
          }

          run {
                    # 'run' mode always has a MSGID; fetch and process it
                    keylget args MSGID mh
                    #First, parse the data to get  the message type
                    set cont [msgget $mh]
                    # parse the input ib Mime message
                    set ih1 [ibmimecreate $cont]
                    # the 1st part (Part ID = 0) content is XML message
                    set data [ibpartcontentget $ih1 0]
                    # set the new message content as the inbound message
                    msgset $mh $data
                    lappend dispList "CONTINUE $mh"

          }

          time {
                       # Timer-based processing
                            # N.B.: there may or may not be a MSGID key in args
          }
        
          shutdown {
                            # Doing some clean-up work 
                   }
     }

     return $dispList
}