/// <summary> Create a EMS MapMessage for the given Map.</summary>
        /// <param name="map">the Map to convert
        /// </param>
        /// <param name="session">current EMS session
        /// </param>
        /// <returns> the resulting message
        /// </returns>
        /// <throws>  EMSException if thrown by EMS methods </throws>
        protected virtual MapMessage CreateMessageForMap(IDictionary map, ISession session)
        {
            MapMessage mapMessage = session.CreateMapMessage();

            foreach (DictionaryEntry entry in map)
            {
                if (!(entry.Key is string))
                {
                    throw new MessageConversionException("Cannot convert non-String key of type [" +
                                                         (entry.Key != null ? entry.Key.GetType().FullName : null) +
                                                         "] to MapMessage entry");
                }
                mapMessage.SetObject(entry.Key.ToString(), entry.Value);
            }
            return(mapMessage);
        }