.Net Validation error

Dear Support Team,
We have built our e-invoicing solution around ZATCA DLL 4.8. It works fine with updates(3.3.0, 3.3.2, and 3.3.3), but when we try to use the 3.3.4 and above updates, we face issues validating the invoices.

{
  "IsValid": false,
  "ValidationSteps": [
    {
      "ValidationStepName": "Initialization Step (Simplified EInvoice)",
      "IsValid": true,
      "ErrorMessages": [],
      "WarningMessages": []
    },
    {
      "ValidationStepName": "Validate XSD",
      "IsValid": true,
      "ErrorMessages": [],
      "WarningMessages": []
    },
    {
      "ValidationStepName": "Validate EN Schematrons",
      "IsValid": false,
      "ErrorMessages": [
        "[Error] occurred in validating Schematrons."
      ],
      "WarningMessages": []
    },
    {
      "ValidationStepName": "Validate KSA Schematrons",
      "IsValid": false,
      "ErrorMessages": [
        "[Error] occurred in validating Schematrons."
      ],
      "WarningMessages": []
    },
    {
      "ValidationStepName": "Generate EInvoice Hash",
      "IsValid": true,
      "ErrorMessages": [],
      "WarningMessages": []
    },
    {
      "ValidationStepName": "Parse Certificate",
      "IsValid": true,
      "ErrorMessages": [],
      "WarningMessages": []
    },
    {
      "ValidationStepName": "Generate EInvoice QR",
      "IsValid": true,
      "ErrorMessages": [],
      "WarningMessages": []
    },
    {
      "ValidationStepName": "Validate QR Code",
      "IsValid": true,
      "ErrorMessages": [],
      "WarningMessages": []
    },
    {
      "ValidationStepName": "Validate EInvoice Signature",
      "IsValid": true,
      "ErrorMessages": [],
      "WarningMessages": []
    },
    {
      "ValidationStepName": "Validate EInvoice PIH",
      "IsValid": true,
      "ErrorMessages": [],
      "WarningMessages": []
    }
  ]
}

signing process was successful. The issue only occurred when I validated the signed document using 3.3.4 and above DLL.

If I validate the signed document using SDK I get a successful result.

it seems that .net DLL 4.8 and above has issues with validation. I have seen many topics from other people who have faced the same issue.

best regards,
Adnan

Dear @ad.almusbahi

Thanks for reaching out,

Can I kindly ask you to elaborate more by mention the steps that you are following, what are the parameters that you are sending?

Thanks,
Ibrahem Daoud.

Thanks, Ibrahem for the replay,
I am doing the steps as following:

  1. Read the XML file from the path.
  2. Call sign function:
SignResult signResult = new EInvoiceSigner().SignDocument(LoadXML(unsignedXMLData), PCSID, privateKey);
  1. After the sign is successful then call the validation function:
ValidationResult validationResult = new EInvoiceValidator().ValidateEInvoice(signResult.SignedEInvoice, PCSID, pihContent);
  1. The result of valuation: on SDK 3.3.3:
{
  "IsValid": true,
  "ValidationSteps": [
    {
      "ValidationStepName": "Initialization Step (Simplified EInvoice)",
      "IsValid": true,
      "ErrorMessages": [],
      "WarningMessages": []
    },
    {
      "ValidationStepName": "Validate XSD",
      "IsValid": true,
      "ErrorMessages": [],
      "WarningMessages": []
    },
    {
      "ValidationStepName": "Validate EN Schematrons",
      "IsValid": true,
      "ErrorMessages": [],
      "WarningMessages": []
    },
    {
      "ValidationStepName": "Validate KSA Schematrons",
      "IsValid": true,
      "ErrorMessages": [],
      "WarningMessages": []
    },
    {
      "ValidationStepName": "Generate EInvoice Hash",
      "IsValid": true,
      "ErrorMessages": [],
      "WarningMessages": []
    },
    {
      "ValidationStepName": "Parse Certificate",
      "IsValid": true,
      "ErrorMessages": [],
      "WarningMessages": []
    },
    {
      "ValidationStepName": "Generate EInvoice QR",
      "IsValid": true,
      "ErrorMessages": [],
      "WarningMessages": []
    },
    {
      "ValidationStepName": "Validate QR Code",
      "IsValid": true,
      "ErrorMessages": [],
      "WarningMessages": []
    },
    {
      "ValidationStepName": "Validate EInvoice Signature",
      "IsValid": true,
      "ErrorMessages": [],
      "WarningMessages": []
    },
    {
      "ValidationStepName": "Validate EInvoice PIH",
      "IsValid": true,
      "ErrorMessages": [],
      "WarningMessages": []
    }
  ]
}

The result of valuation: on SDK 3.3.6 for the same XML file:

{
  "IsValid": false,
  "ValidationSteps": [
    {
      "ValidationStepName": "Initialization Step (Simplified EInvoice)",
      "IsValid": true,
      "ErrorMessages": [],
      "WarningMessages": []
    },
    {
      "ValidationStepName": "Validate XSD",
      "IsValid": true,
      "ErrorMessages": [],
      "WarningMessages": []
    },
    {
      "ValidationStepName": "Validate EN Schematrons",
      "IsValid": false,
      "ErrorMessages": [
        "[Error] occurred in validating Schematrons."
      ],
      "WarningMessages": []
    },
    {
      "ValidationStepName": "Validate KSA Schematrons",
      "IsValid": false,
      "ErrorMessages": [
        "[Error] occurred in validating Schematrons."
      ],
      "WarningMessages": []
    },
    {
      "ValidationStepName": "Generate EInvoice Hash",
      "IsValid": true,
      "ErrorMessages": [],
      "WarningMessages": []
    },
    {
      "ValidationStepName": "Parse Certificate",
      "IsValid": true,
      "ErrorMessages": [],
      "WarningMessages": []
    },
    {
      "ValidationStepName": "Generate EInvoice QR",
      "IsValid": true,
      "ErrorMessages": [],
      "WarningMessages": []
    },
    {
      "ValidationStepName": "Validate QR Code",
      "IsValid": true,
      "ErrorMessages": [],
      "WarningMessages": []
    },
    {
      "ValidationStepName": "Validate EInvoice Signature",
      "IsValid": true,
      "ErrorMessages": [],
      "WarningMessages": []
    },
    {
      "ValidationStepName": "Validate EInvoice PIH",
      "IsValid": true,
      "ErrorMessages": [],
      "WarningMessages": []
    }
  ]
}

Dear @ad.almusbahi

Thanks for collaborate,

As you can see the errors appear when using SDK3.3.6 are related to (“Validate EN Schematrons”, and “Validate KSA Schematrons”)
which means that the provided XML contains some business errors,
our recommendation is to use SDK to validate the XML and see the error code for each error even in KSA rules or EN rules, and try to fix it and send the invoice after fixing the errors, it might be related to some calculations,

You can also rely on the API response when submitting the signed XML, to see the errors codes in your XML.

Additionally, Kindly note that no errors are related to sign process.

If you faced any issues while fixing it, kindly share the XML to SP email and they will provide you with the right way to fix it based ion your XML.

Please find SP email: sp_support@zatca.gov.sa

Thanks,
Ibrahem Daoud.

Dear @idaoud ,

There is no issue with the XML, I validated the same XML file with JAVA SDK 3.3.6 it was a success without any warning or errors.
Even when I validate the file with .net 8.0 it’s working fine.
The issue is with 3.3.4 and above 4.8 framework library only.

best regards,
Adnan

Hello there ,

The last sdk version 3.3.5, most developers in the site: https://zatca1.discourse.group/

Most developers have a problem that is when we test the fatooraNet.exe, its working fine in signing process and validating.

But when we use Zatca.EInvoice.SDK.dll especially for 4.8 the signing process is succeeded, but the validating process is failed AND I found the failure reason

The reason is due to the resource files you added in the dll

You were added this file as embedded resource in you dll project

SDK.Zatca.EInvoice.SDK.Data.addQRElement.xsl

SDK.Zatca.EInvoice.SDK.Data.addSignatureElement.xsl

SDK.Zatca.EInvoice.SDK.Data.addUBLElement.xsl

SDK.Zatca.EInvoice.SDK.Data.invoice.xsl

SDK.Zatca.EInvoice.SDK.Data.removeElements.xsl

SDK.Zatca.EInvoice.SDK.Data.Schematrons.20210819_ZATCA_E-invoice_Validation_Rules.xsl

SDK.Zatca.EInvoice.SDK.Data.Schematrons.CEN-EN16931-UBL.xsl

SDK.Zatca.EInvoice.SDK.Data.qr.xml

SDK.Zatca.EInvoice.SDK.Data.signature.xml

SDK.Zatca.EInvoice.SDK.Data.ubl.xml

SDK.Zatca.EInvoice.SDK.Data.XSD.CCTS_CCT_SchemaModule-2.1.xsd

SDK.Zatca.EInvoice.SDK.Data.XSD.UBL-CommonAggregateComponents-2.1.xsd

SDK.Zatca.EInvoice.SDK.Data.XSD.UBL-CommonBasicComponents-2.1.xsd

SDK.Zatca.EInvoice.SDK.Data.XSD.UBL-CommonExtensionComponents-2.1.xsd

SDK.Zatca.EInvoice.SDK.Data.XSD.UBL-CommonSignatureComponents-2.1.xsd

SDK.Zatca.EInvoice.SDK.Data.XSD.UBL-CoreComponentParameters-2.1.xsd

SDK.Zatca.EInvoice.SDK.Data.XSD.UBL-ExtensionContentDataType-2.1.xsd

SDK.Zatca.EInvoice.SDK.Data.XSD.UBL-Invoice-2.1.xsd

SDK.Zatca.EInvoice.SDK.Data.XSD.UBL-QualifiedDataTypes-2.1.xsd

SDK.Zatca.EInvoice.SDK.Data.XSD.UBL-SignatureAggregateComponents-2.1.xsd

SDK.Zatca.EInvoice.SDK.Data.XSD.UBL-SignatureBasicComponents-2.1.xsd

SDK.Zatca.EInvoice.SDK.Data.XSD.UBL-UnqualifiedDataTypes-2.1.xsd

SDK.Zatca.EInvoice.SDK.Data.XSD.UBL-XAdESv132-2.1.xsd

SDK.Zatca.EInvoice.SDK.Data.XSD.UBL-XAdESv141-2.1.xsd

SDK.Zatca.EInvoice.SDK.Data.XSD.UBL-xmldsig-core-schema-2.1.xsd

And you access them via ConfigurationManager Class as static properties and load it’s values by ReadResource Method

public static string ReadResource(string resource)

{

return new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream(resource)).ReadToEnd();

}

And you pass the resource name as following

internal static string EN_Schematrons = ReadResource(“Zatca.EInvoice.SDK.Data.Schematrons.CEN-EN16931-UBL.xsl”);

I tried your code after I reflected it and have the same error and the solution is to use this code instead

public static string ReadResource(string resource)

{

return new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream(Assembly.GetExecutingAssembly().GetName().Name + “.” + resource)).ReadToEnd();

}

The most important segment is

Assembly.GetExecutingAssembly().GetName().Name + “.” + resource

Even though tow ways give the same string value

You pass the string as full path or Assembly.GetExecutingAssembly().GetName().Name + “.” + resource

ONLY the second way will work.

I hope this email reach you development team, and I hope you telling me that it reached

I also hope you release a new version ASAP.

Thanks a lot

@ad.almusbahi , @idaoud @hadarasoft I think we all should attend the Zatca live session held every Thursday to raise our issue. when multiple people raise the point in a live session it may effect. As no one is responding on emails regarding this issue.

Dears @sehrish02101998, @hadarasoft, @ad.almusbahi

Please note that it is a known issue and will be new release for .net farmwork ASAP.

Thanks in advance,
Ibrahem Daoud.