I am using new updated ediFabric 6.7.7 and i am trying to validate generic message - so i can not cast it to particular class of particular version.
I have an issue with xml serialization.
This code works (it is pretty similar to code in ediFabric unit tests)
var invoice = (M_810) msg.Value;
var validation = new List<string>(invoice.ValidateX12(xsdStream));
but this throws an exception
var validation = new List<string>(msg.Value.ValidateX12(xsdStream));
System.InvalidOperationException: The type EdiFabric.Rules.X12004010810.M_810 was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically
So my question is - is it somehow possible to validate generic message, w\o explicitly casting it to particular class.
The way i am getting correct schema here is via GS Header and ST01 via reflection.
Of course i can write my own Xml Serializer and vaildate against Xsd schema using XsdSchemaCollection
, but EdiMessage<S_ISA, S_GS>
contains ValidateX12()
method and i want to use it if possible.
This is now available in version 6.8.2. You can call it like: var validation = new List(msg.Value.Validate());
It now resolves internally the xsd and the format.