TIBCO Messages to POCO and Vice-Versa

137 views Asked by At

I have been doing some TIBCO dev recently, and wondering what is the best way out there for converting to/from TIBCO messages?

This is what I'm currently doing, but i know there must be a better way to do this. But my brain is fried at the moment, and searching on Bing/Google or SO is not returning anything useful.

    public static Envelope ParseEnvelope(Message msg)
    {
        try
        {
            var field = msg.GetField("Envelope");
            if(field == null) throw new ArgumentException("msg does not contain Envelope field", "msg");

            var envMsg = field.Value as Message;
            if(envMsg == null) throw new ArgumentException("msg.Envelope field is null or not a Message", "msg");

            var envTypeField = envMsg.GetField("EnvelopeEventId");
            if (envTypeField == null) throw new ArgumentException("msg.Envelope does contain EnvelopeEventId field");

            var envType = envTypeField.Value as String;
            if (envType == null) throw new ArgumentException("msg.Envelope.EnvelopeEventId field is null or not a String", "msg");

            var env = new Envelope(envType);

        }

Any help, or pointers are appreciated!

Right now I am thinking of creating my own type of AutoMapper for converting To/From messages which would look at a specific "Field" in the root of the TIBCO message to get what class it should convert to, and then use reflection (first time, if not in cache) for the tree of properties on that class recursively (if any property is not a value type)

0

There are 0 answers