Fixml Converter Sample
Source code
using System;
using System.IO;
using OnixS.Fix;
namespace FixmlConverter
{
static class FixmlConverterSample
{
static int Main()
{
try
{
var converter = new OnixS.Fix.Fix2FixmlConverter.FixmlConverter(ProtocolVersion.Fix50sp2);
string inputFile = "SecDef.xml";
Log($"Will load the FIXML message from the {inputFile} file.\n");
string inputFixmlMessage = File.ReadAllText(inputFile);
Log($"Input FIXML message:\n{inputFixmlMessage}\n");
Message fixMessage = converter.Fixml2Fix(inputFixmlMessage);
Log($"Converted FIX message:\n{fixMessage}\n");
string convertedFixmlMessage = converter.Fix2Fixml(fixMessage);
Log($"Converted FIXML message:\n{convertedFixmlMessage}\n");
}
catch (Exception ex)
{
Console.WriteLine($"Exception: {ex}");
return 1;
}
return 0;
}
private static void Log(string message)
{
Console.WriteLine(message);
}
}
}
FIXML message
<FIXML>
<SecDef
RspTyp="100"
ReqID="1234567"
RptID="3400001">
<Hdr
SID="CME"
SSub="CPAPI "
TID="BRKR"
TSub="user123"/>
<Instrmt
ID="CS"
Src="H"
Desc="WTI Calendar Swap"
SecTyp="FUT"
Exch="NYMEX"
ProdCmplx="ENRGY"
TmUnit="Mo"
UOM="Bbl"
UOMQty="1000"
PxUOM="Bbl"
PxUOMQty="1"
PxQteMeth="STD"
MinPxIncr="0.01"
SettlMeth="C"
ListMeth="0"/>
<InstrmtExt>
<Attrb Typ="29" Val="Y"/>
<Attrb Typ="25" Val="1"/>
<Attrb Typ="24" Val="2"/>
<Attrb Typ="24" Val="12"/>
</InstrmtExt>
</SecDef>
</FIXML>