Re: [Quickfix-developers] How do I change the field of a message from the .net api?
Brought to you by:
orenmnero
From: Andrei G. <an...@gm...> - 2009-01-09 16:20:57
|
On Fri, Jan 9, 2009 at 1:54 AM, Wilhelm Thomas <th...@cu...> wrote: > QuickFIX Documentation: http://www.quickfixengine.org/quickfix/doc/html/index.html > QuickFIX Support: http://www.quickfixengine.org/services.html > > > hello > > Happy new year to all! > > I'm using the .net api > > I'm working on a gateway, I receive a message from my acceptor function > > fromApp( > > Message message, SessionID sessionID) > > 1) I basically need to change some fields from this message and forward back the message to my Initiator > > I'm basically doing this: > > > message.removeField((int)49); > message.removeField(56); > Console.Out.WriteLine(">>>> m=" + message.ToString()); > message.setField(49, "MAXP2"); // SenderCompID > message.setField(56, "MAX2PRICE"); // TargetCompID > Console.Out.WriteLine(">>>> m=" + message.ToString()); > message.setString(49, "MAXP2"); // SenderCompID > message.setString(56, "MAX2PRICE"); // TargetCompID > Console.Out.WriteLine(">>>> m=" + message.ToString()); > > > but when I call some ,remove, replace, setField, setString, nothing change the > fields 49 and 56? You are setting header fields into the body. This is a no-no. The correct way to do it would be: message.getHeader().setString(49, "MAXP2"); // SenderCompID message.getHeader().setString(56, "MAX2PRICE"); // TargetCompID Anyway, keep in mind that if you want to send this message via QuickFIX (i.e. SendToTarget), MAXP2-MAX2PRICE must be a valid session defined in your coniguration file. > > 2) I also try to loop over the fields and create a new message but I do not get the correct field > > System.Collections. > > IEnumerator enum_ = message.GetEnumerator(); > QuickFix.Field key = null; > while(enum_.MoveNext()){ > key = (Field)enum_.Current; > message2.setField(key.getField(), (string)key.getObject()); > } > > Here is what I see once this while execute: > > + message {8=FIX.4.2 9=225 35=V 34=2 49=BLABLA 52=20090109-03:49:01.464 56=GATEWAY146=1 55=6E Sep08 48=6E012008090000003232 167=FUT 200=200809 202=0 207=TTSIM 262=1/8/2009 7:49:01 PM172 263=1 264=10 265=1 266=Y 267=3 269=0 269=1 269=2 10=192 } QuickFix.Message {QuickFix42.MarketDataRequest} > > + message2 {8=FIX.4.2 9=69 35=V 146=1 262=1/8/2009 7:49:01 PM172 263=1 264=10 265=1 266=Y 267=3 10=251 } QuickFix42.MarketDataRequest > > Which is weird as message2 isn't at all like message? > > Any idea why? 1) You are not iterating over header/trailer fields. 2) You won't get fields in repeating group, as they are kept in separate structures. |