EDI Integrator V9 - Online Help
Available for:
EDI Integrator V9
Questions / Feedback?

AS4Client Component

Properties   Methods   Events   Configuration Settings   Errors  

The AS4Client component connects to a server to send or receive files.

Syntax

nsoftware.InEDI.As4client

Remarks

The AS4Client component may be used to send or receive files from a server. The component will connect to a server and either send files (push), or request files to download (pull).

Sending Files

SendFiles sends the files specified by EDIData to URL.

Before calling this method set AgreementRef to the agreement identifier used by both parties. Set AS4From and AS4To. Set EDIData specifies the file(s) to be sent. To encrypt the data set RecipientCerts. To sign the data set SigningCert. The SignerCert property should be set to verify the signed receipt.

When this method is called the file(s) will be sent and any returned receipts will be verified.

To indicate a synchronous receipt is expected set ReceiptReplyMode to rrmSync. The following properties are applicable when calling this method with an agreement specifying a synchronous receipt (a receipt provided in the response):

SendFiles Example (synchronous receipt):

client.Profile = As4clientProfiles.ebpfENTSOG;

//Specify the agreement and party information
client.AgreementRef = "http://agreements.company.com/sign_and_encrypt";

client.AS4From.Role = "Sender";
client.AS4From.Id = "org:b2b:example:company:A";

client.AS4To.Role = "Receiver";
client.AS4To.Id = "org:b2b:example:company:B";
      
//Configure the component to expect a synchronous receipt.      
client.ReceiptReplyMode = As4clientReceiptReplyModes.rrmSync;

//Company A's private certificate. Used to sign the outgoing message and files.
client.SigningCert = new Certificate(CertStoreTypes.cstPFXFile, "C:\\files\\CompanyA.pfx", "password", "*");

//Company B's public certificate. Used to encrypt the outgoing file.
client.RecipientCerts.Add(new Certificate("C:\\files\\as4\\CompanyB.cer"));

//Company B's public certificate. Used to verify the signed receipt.
client.SignerCert = new Certificate("C:\\files\\as4\\CompanyB.cer");

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

EBData data = new EBData();
data.EDIType = "application/edi-x12";
data.Filename = "C:\\files\\myfile.x12";
data.Name = "myfile.x12";

client.EDIData.Add(data);

//Send file(s) and verify the receipt.
client.SendFiles();

The component also supports asynchronous receipts. In this configuration a file is sent from the component to another party, but the receipt is not returned in the response. Instead the other party sends the receipt at a later time. The AS4Server component may be used inside a web page to receive the asynchronous receipt. After receiving the receipt either AS4Server or AS4Client may be used to verify the receipt.

Details about the original message must be stored so that the receipt can be correlated with the message and properly verified. The easiest way to do this is to set AsyncReceiptInfoDir before calling SendFiles. The component will automatically store the required information.

See the VerifyReceipt method of AS4Server for details about verifying asynchronous receipts.

To indicate an asynchronous receipt is expected set ReceiptReplyMode to rrmAsync. The following properties are applicable when calling this method with an agreement specifying a synchronous receipt (a receipt provided in the response):

SendFiles Example (asynchronous receipt):

client.Profile = As4clientProfiles.ebpfENTSOG;

//Specify the agreement and party information
client.AgreementRef = "http://agreements.company.com/sign_and_encrypt_async";

client.AS4From.Role = "Sender";
client.AS4From.Id = "org:b2b:example:company:A";

client.AS4To.Role = "Receiver";
client.AS4To.Id = "org:b2b:example:company:B";
      
//Configure the component to expect a synchronous receipt.      
client.ReceiptReplyMode = As4clientReceiptReplyModes.rrmAsync;

client.AsyncReceiptInfoDir = "C:\\async_info";

//Company A's private certificate. Used to sign the outgoing message and files.
client.SigningCert = new Certificate(CertStoreTypes.cstPFXFile, "C:\\files\\CompanyA.pfx", "password", "*");

//Company B's public certificate. Used to encrypt the outgoing files.
client.RecipientCerts.Add(new Certificate("C:\\files\\as4\\CompanyB.cer"));

//Company B's public certificate. Used to verify the signed receipt.
client.SignerCert = new Certificate("C:\\files\\as4\\CompanyB.cer");

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

EBData data = new EBData();
data.EDIType = "application/edi-x12";
data.Filename = "C:\\files\\myfile.x12";
data.Name = "myfile.x12";

client.EDIData.Add(data);

//Send file(s).
client.SendFiles();

At this point the file(s) have been sent, but a receipt has not yet been received. AS4Server can be used within a web site to listen for the receipt.

//**** Inside a web site ****
As4server server = new As4server;
server.ReadRequest();

if (!String.IsNullOrEmpty(server.IncomingReceipt.Content))
{
  server.AsyncReceiptInfoDir = "C:\\async_info";
  server.VerifyReceipt();
  //The receipt is now verified
}

Receiving Files

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

Sending Asynchronous Receipts

SendReceipt sends an asynchronous receipt to the URL.

This method is typically used in conjunction with AS4Server to send an asynchronous receipt after receiving a message. The receipt will be created at the time of the incoming request, then saved for later use. When the receipt is to be sent populate Receipt and call this method.


//Send an asynchronous receipt
client.URL = ""http://www.company.com:9090/msh"";
client.Receipt = new EBReceipt(server.Receipt.RefToMessageId, server.Receipt.Content);
client.ReceiptReplyMode = As4clientReceiptReplyModes.rrmAsync;
client.SendReceipt();

Property List


The following is the full list of the properties of the component with short descriptions. Click on the links for further details.

AgreementRefThe agreement reference.
AS4FromDefines information about the originating party.
AS4ToDefines information about the responding party.
AsyncReceiptInfoDirA directory to hold information used for asynchronous receipt verification.
CertificateThe certificate with private key used for decryption.
CompressionFormatThe compression format (if any) to use.
ConversationIdThe Conversation Id of the message.
CookiesCollection of cookies.
EDIDataThe EDI data.
EncryptionAlgorithmThe algorithm used to encrypt the EDI data.
ErrorsA collection of errors.
FirewallA set of properties related to firewall access.
IncomingDirectoryThe directory to which incoming files are saved.
LocalHostThe name of the local host or user-assigned IP interface through which connections are initiated or accepted.
LogDirectoryThe path to a directory for logging.
LogFileThe log file written.
MessageIdThe unique Id of the message.
MessagePropertiesA collection of message properties.
MPCThe MPC (Message Partition Channel) from which to receive files.
OriginalSOAPMessageThe original SOAP message used to verify the receipt.
OriginalSOAPMessageIdThe original SOAP message Id used to verify the receipt.
ProfileThe AS4 profile.
ProxyA set of properties related to proxy access.
ReceiptThe receipt of a message.
ReceiptReplyModeThe expected receipt reply mode.
RecipientCertsThe public certificate used to encrypt files when sending.
RefToMessageIdSpecifies the RefToMessageId in the message.
ServiceThe service which acts on the message.
ServiceActionThe action within a service that acts on the message.
ServiceTypeThe type of service.
SignatureAlgorithmSignature algorithm to be used in the message.
SignerCertThe public certificate used to verify signatures.
SigningCertThe certificate with private key used to sign messages and files.
SSLAcceptServerCertInstructs the component to unconditionally accept the server certificate that matches the supplied certificate.
SSLCertThe certificate to be used during SSL negotiation.
SSLServerCertThe server certificate for the last established connection.
TimeoutA timeout for the component.
TokenPasswordThe password used in UsernameToken authentication.
TokenPasswordTypeThe password type used in UsernameToken authentication.
TokenUserThe username used in UsernameToken authentication.
URLThe URL to which the request is made.

Method List


The following is the full list of the methods of the component with short descriptions. Click on the links for further details.

ConfigSets or retrieves a configuration setting .
DoEventsProcesses events from the internal message queue.
InterruptInterrupt the current method.
ReceiveFilesConnects to a server to receive files.
ResetResets the state of the control.
SendFilesSends file(s) to the specified server and verify the receipt (if present).
SendReceiptSends an asynchronous receipt.

Event List


The following is the full list of the events fired by the component with short descriptions. Click on the links for further details.

ConnectedFired immediately after a connection completes (or fails).
DisconnectedFired when a connection is closed.
EndTransferFired when a document finishes transferring.
ErrorInformation about errors during data delivery.
HeaderFired every time a header line comes in.
LogProvides logging information.
RecipientInfoFired for each recipient certificate of the encrypted message.
SetCookieFired for every cookie set by the server.
SignerCertInfoFired during verification of the signed message.
SSLServerAuthenticationFired after the server presents its certificate to the client.
SSLStatusShows the progress of the secure connection.
StartTransferFired when a document starts transferring (after the headers).
TransferFired while a document transfers (delivers document).

Configuration Settings


The following is a list of configuration settings for the component with short descriptions. Click on the links for further details.

AllowWarningsWhether warnings are interpreted as fatal errors.
AgreementRefTypeThe type of AgreementRef.
AgreementRefPModeAgreementRef PMode of message.
AttachXMLFilesWhether to send XML files as attachments or within the SOAP body.
CloseStreamAfterProcessingWhether to close the input or output stream after processing.
CompressXMLPayloadsWhether to compress XML data.
DetectDuplicatesWhether to detect duplicate messages when receiving.
EBPrefixSpecifies the prefix to use for messaging.
EDIDataPartId[i]Specified the part Id at the given index.
EncryptionSecurityTokenFormatThe format to use for the security token when encryption.
SigningSecurityTokenFormatThe format to use for the security token when signing.
FilenamePropertyDefines a part property to hold the filename.
IdRightA custom Id for the right side of the MessageId.
FromIdCountThe number of Ids for the party specified by AS4From.
FromId[i]The Id of the party specified by AS4From.
FromIdType[i]The Id type of the party specified by AS4From.
LogLevelThe level of information to log.
LogOptionsThe information to be written to log files.
MessageTypeIndicates the type of message received.
MGF1HashAlgorithmThe MGF1 hash algorithm used when encrypting a key.
RequireEncryptionWhether encryption is required when processing received messages.
RequireSignatureWhether a signature is required when processing received messages.
NormalizeIssuerSubjectWhether to normalize the certificate subject within the X509Data element.
RSAHashAlgorithmThe RSA hash algorithm used when encrypting a key.
OAEPParamsThe hex encoded OAEP parameters to be used when encrypting a key.
ToIdCountThe number of Ids for the party specified by AS4To.
ToId[i]The Id of the party specified by AS4To.
ToIdType[i]The Id type of the party specified by AS4To.
TransformReceiptWhether to canonicalize the received receipt.
UseNonceWhether to use a nonce in UsernameToken authentication.
AuthSchemeThe authorization scheme to be used when server authorization is to be performed.
AuthorizationThe Authorization string to be sent to the server.
UserA user name if authentication is to be used.
PasswordA password if authentication is to be used.
AcceptEncodingUsed to tell the server which types of content encodings the client supports.
AllowHTTPCompressionThis property enables HTTP compression for receiving data.
AllowIdenticalRedirectURLAllow redirects to the same URL.
AppendWhether to append data to LocalFile.
AuthorizationThe Authorization string to be sent to the server.
BytesTransferredContains the number of bytes transferred in the response data.
EncodeURLIf set to true the URL will be encoded by the component.
FollowRedirectsDetermines what happens when the server issues a redirect.
GetOn302RedirectIf set to true the component will perform a GET on the new location.
HTTPVersionThe version of HTTP used by the component.
IfModifiedSinceA date determining the maximum age of the desired document.
KeepAliveDetermines whether the HTTP connection is closed after completion of the request.
MaxRedirectAttemptsLimits the number of redirects that are followed in a request.
OtherHeadersOther headers as determined by the user (optional).
ProxyAuthorizationThe authorization string to be sent to the proxy server.
ProxyAuthSchemeThe authorization scheme to be used for the proxy.
ProxyPasswordA password if authentication is to be used for the proxy.
ProxyPortPort for the proxy server (default 80).
ProxyServerName or IP address of a proxy server (optional).
ProxyUserA user name if authentication is to be used for the proxy.
TransferredDataLimitThe maximum number of incoming bytes to be stored by the component.
TransferredHeadersThe full set of headers as received from the server.
UseChunkedEncodingEnables or Disables HTTP chunked encoding for transfers.
ChunkSizeSpecifies the chunk size in bytes when using chunked encoding.
UserAgentInformation about the user agent (browser).
KerberosSPNThe Service Principal Name for the Kerberos Domain Controller.
ConnectionTimeoutSets a separate timeout value for establishing a connection.
FirewallAutoDetectTells the component whether or not to automatically detect and use firewall system settings, if available.
FirewallHostName or IP address of firewall (optional).
FirewallPasswordPassword to be used if authentication is to be used when connecting through the firewall.
FirewallPortThe TCP port for the FirewallHost;.
FirewallTypeDetermines the type of firewall to connect through.
FirewallUserA user name if authentication is to be used connecting through a firewall.
KeepAliveTimeThe inactivity time in milliseconds before a TCP keep-alive packet is sent.
KeepAliveIntervalThe retry interval, in milliseconds, to be used when a TCP keep-alive packet is sent and no response is received.
LingerWhen set to True, connections are terminated gracefully.
LingerTimeTime in seconds to have the connection linger.
LocalHostThe name of the local host through which connections are initiated or accepted.
LocalPortThe TCP port in the local host where the component binds.
MaxLineLengthThe maximum amount of data to accumulate when no EOL is found.
MaxTransferRateThe transfer rate limit in bytes per second.
RecordLengthThe length of received data records.
TCPKeepAliveDetermines whether or not the keep alive socket option is enabled.
UseIPv6Whether to use IPv6.
TcpNoDelayWhether or not to delay when sending packets.
ReuseSSLSessionDetermines if the SSL session is reused.
SSLCipherStrengthThe minimum cipher strength used for bulk encryption.
SSLEnabledProtocolsUsed to enable/disable the supported security protocols.
SSLProviderThe name of the security provider to use.
SSLSecurityFlagsFlags that control certificate verification.
OpenSSLCADirThe path to a directory containing CA certificates.
OpenSSLCAFileName of the file containing the list of CA's trusted by your application.
OpenSSLCipherListA string that controls the ciphers to be used by SSL.
OpenSSLPrngSeedDataThe data to seed the pseudo random number generator (PRNG).
AbsoluteTimeoutDetermines whether timeouts are inactivity timeouts or absolute timeouts.
FirewallDataUsed to send extra data to the firewall.
InBufferSizeThe size in bytes of the incoming queue of the socket.
OutBufferSizeThe size in bytes of the outgoing queue of the socket.
CodePageThe system code page used for Unicode to Multibyte translations.

 
 
Copyright (c) 2018 /n software inc. - All rights reserved.
Build 9.0.6635.0