独立的AS2客户端用于传输文件



我需要将文件(XML)传输到AS2服务器。我在这个通信渠道上并不擅长,但是我需要以编程方式进行。例如,发送到SFTP我正在使用此代码:

import com.jcraft.jsch.*;
.......
public void uploadViaSFTP (String fileToUpload, String sftp_host, String sftp_user, String sftp_psw) 
    {
        int    SFTPPORT = 22;
        Session     session     = null;
        Channel     channel     = null;
        ChannelSftp channelSftp = null;
        try{
            JSch jsch = new JSch();
            session = jsch.getSession(sftp_user,sftp_host,SFTPPORT);
            session.setPassword(sftp_psw);
            java.util.Properties config = new java.util.Properties();
            //this line should be used only for testing, not for production
            config.put("StrictHostKeyChecking", "no");
            session.setConfig(config);
            session.connect();
            channel = session.openChannel("sftp");
            channel.connect();
            channelSftp = (ChannelSftp)channel;
            channelSftp.cd("/");
            File f = new File(fileToUpload);
            channelSftp.put(new FileInputStream(f), f.getName());
        }catch(Exception ex){
            ex.printStackTrace();
        }
}

,但是现在我需要对AS2进行同样的操作。我可以使用哪个库(OpenAS2)?是否有一种简单的方法可以像SFTP一样转移?

您应该能够使用标准的HTTPS组件和S/MIME附件,因为AS2是HTTP或HTTPS顶部的安全层和使用规范。

我将从(https://www.mkyong.com/java/java/java-https-client-httpsurlconnection-example/),AS2规范(http://www.ietf.org/rfc/rfc/rfc/rfc4130)。

最新更新