-
Notifications
You must be signed in to change notification settings - Fork 562
User FAQ
This FAQ is very young.
You read the tutorial, right?
In your IApplication
, put this in your ToAdmin
method:
public void ToAdmin(Message message, SessionID sessionID)
{
if(message.Header.GetField(Tags.MsgType)==MsgType.LOGON){
message.SetField(new QuickFix.Fields.Username("batman"));
message.SetField(new QuickFix.Fields.Password("gotham123"));
}
}
Yes! This is commonly done with usernames/passwords that the app will insert into Logon messages.
Here is some example code showing you how you can loop through all the sessions defined in your settings file and extract a custom setting "Woot" if it is defined in the session:
// Create object from file that you supply
QuickFix.SessionSettings settings = new QuickFix.SessionSettings(file);
// Get all the session IDs
HashSet<SessionID> sids = settings.GetSessions();
// For each session ID, get the session's settings and look for "Woot" key
foreach (SessionID sid in sids)
{
Console.WriteLine("==SessionID: " + sid.ToString()+"==");
Dictionary settingsDict = settings.Get(sid);
if (settingsDict.Has("Woot"))
Console.WriteLine("Woot=" + settingsDict.GetString("Woot"));
else
Console.WriteLine("Does not have Woot");
}
I am continually surprised by how many people want to do this. Where are you guys getting your FIX strings from if not from a live FIX connection?
Anyway, you want Message.FromString()
. Use it like follows:
string msgStr = <your message>
var dd = new QuickFix.DataDictionary.DataDictionary();
dd.Load("some/path/FIX44.xml"); // or whatever file
IMessageFactory defaultMsgFactory = new DefaultMessageFactory();
var msg = new QuickFix.FIX44.ExecutionReport();
msg.FromString(msgStr,true,dd,dd,defaultMsgFactory);
(This is lifted from the unit tests, where this technique is used quite a bit.)
You are either not using a DataDictionary, or your DD is wrong.
A tag cannot appear twice in a message, unless it is within a repeating group.
Without a DataDictionary, the QF/n parser can not know how each group is defined. It will not know when each group begins or ends, or what fields it contains. It is simply impossible to parse repeating groups without a DataDictionary.
In actual practice, you should ALWAYS have a DataDictionary. Nearly all connections "in the wild" use repeating groups.