Discuss this help topic in SecureBlackbox Forum

EDI: Create a receipt for a received AS2/AS3 message

After loading an incoming AS2 or AS3 message it's needed to check if the message requires a receipt to be created and sent to the message originator. This is done by checking Message.ReceiptRequest.Enabled property - it is set to true when a receipt is requested.

In AS3 protocol all receipts are asynchronous.

In AS2 protocol receipts can be both synchronous and asynchronous. So it is necessary to check Message.ReceiptRequest.AsyncReceipt property to find out, whether the message sender expects the receipt in the same HTTP session, or the receipt is to be sent later to the specified URL. If AsyncReceipt property is set to true, the URL for the receipt will be present in in Message.ReceiptRequest.URL property.

The message originator can request a plain receipt or a signed one. To get an idea if the receipt should or has to be signed, it's needed to check Message.ReceiptRequest.Signed and Message.ReceiptRequest.SignatureProtocolRequired properties.

The simplest way to create an AS2 receipt is to call TElAS2Receipt.Assign() method and pass the loaded message to it. The receipt will be configured automatically according to the request settings, and all the issues from the message will be copied to the receipt report. Then it's only needed to provide the certificate to sign the receipt and save the receipt to a stream or to a file. The same principle applies to AS3 receipt as well.

Once the receipt is prepared, you need to send the receipt to the message originator.



TElAS2Receipt receipt = new TElAS2Receipt();

// configure the receipt automatically

// optionally, it's possible to change errors list

// you can remove errors you donít want to be reported
// to the message originator, for example, warnings
int i = 0;
while (i < receipt.Errors.Count)
    // this removes all the warnings found in the original message
    if (receipt.Errors[i].Modifier == TSBASDispositionModifier.dmWarning)
// also, it's possible to add errors and/or warnings
// specific to your application
receipt.Errors.Add(MY_ERROR_CODE, "error-summary", "My error description",

// check if the receipt has to be signed
if (receipt.Signature.Enabled)
    // assign a certificate storage with your certificate and its
    // private key loaded
    receipt.Signature.CertStorage = signingCertificates;

// assemble the receipt and save it to a stream

How To articles about AS2 and AS3 messages

Discuss this help topic in SecureBlackbox Forum