AS3 Code Example: Sending and Receiving


To send and receive files with AS3 follow the sample code below.

//Java //Send an EDI message as3sender.setAS3From("testas3"); as3sender.setAS3To("testas3"); as3sender.getRecipientCerts().add(new inedi.Certificate("c:\\recipient.cer")); as3sender.setSigningCert(new inedi.Certificate(inedi.Certificate.cstPFXFile,"c:\\sender.pfx","test","*")); as3sender.getEDIData().setFilename("c:\\test.txt"); as3sender.setMDNTo("test@nsoftware.com"); //Doesn't matter what this is, specify any value to request a MDN as3sender.setRemoteHost("yourftpserver"); as3sender.setUser("test"); as3sender.setPassword("test"); as3sender.setLogDirectory("c:\\as3logs\\sent"); as3sender.logon(); as3sender.setRemotePath("AS3"); as3sender.send("RemoteFile.txt"); as3sender.logoff(); System.out.println("Request uploaded"); //Record original values to process MDN later String originalContentMIC = as3sender.getOriginalContentMIC(); String messageId = as3sender.getMessageId(); String mdnOptions = as3sender.getMDNOptions(); //With AS3Receiver process the file as3receiver.setSignerCert(new inedi.Certificate("c:\\sender.cer")); as3receiver.setCertificate(new inedi.Certificate(inedi.Certificate.cstPFXFile,"c:\\recipient.pfx","test","*")); as3receiver.setRemoteHost("yourftpserver"); as3receiver.setUser("test"); as3receiver.setPassword("test"); as3receiver.setLogDirectory("c:\\as3logs\\received"); as3receiver.logon(); as3receiver.setRemotePath("AS3"); as3receiver.readRequest("RemoteFile.txt"); as3receiver.processRequest(); as3receiver.sendResponse("AS3Response.txt"); as3receiver.logoff(); //Get the response and verify it as3sender = new As3sender(); as3sender.setReceiptSignerCert(new inedi.Certificate("c:\\recipient.cer")); as3sender.setRemoteHost("yourftpserver"); as3sender.setUser("test"); as3sender.setPassword("test"); as3sender.logon(); as3sender.setRemotePath("AS3"); as3sender.readReceipt("AS3Response.txt"); //Set original message properties for verification as3sender.setMessageId(messageId); as3sender.setOriginalContentMIC(originalContentMIC); as3sender.setMDNOptions(mdnOptions); as3sender.verifyReceipt(); as3sender.deleteFile("AS3Response.txt"); as3sender.logoff();

We appreciate your feedback. If you have any questions, comments, or suggestions about this article please contact our support team at support@nsoftware.com.