ReceiveFiles Method

Connects to a server to receive files.

Syntax

public void ReceiveFiles();
Public Sub ReceiveFiles()

Remarks

ReceiveFiles establishes a connection to the server specified by URL and receives files.

The MPC specifies the Message Partition Channel from which messages will be received. The server will reply with files from this channel. If IncomingDirectory is set before calling this method the files will be written to the specified folder, otherwise inspect EDIData to obtain the received file data. The following properties are applicable when calling this method:

After calling this method the following properties will be populated and may be inspected: The Receipt property will be populated with the receipt corresponding to the received message, but it is not yet delivered. The receipt may be delivered by bundling it with another request to receive files, or by calling SendReceipt.

To bundle the receipt with a subsequent ReceiveFiles call the Receipt property must hold the receipt. If the same instance of the component is being used this is already true since Receipt is populated automatically after receiving the file. To use another instance of the component for multiple calls to ReceiveFiles be sure to save the Receipt's Content and RefToMessageId values for later use.

ReceiveFiles Example:

client.Profile = As4clientProfiles.ebpfENTSOG;

//Company A's private certificate. Used for signing the request.
client.SigningCert = new Certificate(CertStoreTypes.cstPFXFile, "C:\\files\\as4\\CompanyA.pfx", "password", "*");

//Company A's private certificate. Used for decrypting the file.
client.Certificate = new Certificate(CertStoreTypes.cstPFXFile, "C:\\files\\as4\\CompanyA.pfx", "password", "*");

//Company B's public certificate. Used for signature verification.
client.SignerCert = new Certificate("C:\\files\\as4\\CompanyB.cer");

client.URL = "http://www.company.com:9090/msh";

//Message Channel id
client.MPC = "mpc_a";

client.IncomingDirectory = "C:\\incoming_dir";
client.ReceiveFiles();

//Inspect client.AgreementRef and other properties for information about the received files
Console.WriteLine(client.AgreementRef);
Console.WriteLine(client.AS4From.Id);
Console.WriteLine(client.AS4To.Id);
Console.WriteLine(client.ConversationId);

//Save the receipt for later use

string receiptContent = client.Receipt.Content;
string receiptRefId = client.Receipt.RefToMessageId;

At this stage the receipt data is saved. Later when making another call to ReceiveFiles and populate the Receipt property with this receipt data. When ReceiveFiles is called again, the receipt for the previous message will be included with the request.

client.Receipt = new EBReceipt(receiptRefId, receiptContent);
client.ReceiveFiles(); //This will now include the bundled receipt

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks EDI 2020 .NET Edition - Version 20.0 [Build 8203]