2
ファイル(xml)をAS2サーバーに転送する必要があります。私はこのコミュニケーションチャンネルがあまりよくありませんが、私はそれをプログラムで行う必要があります。たとえば、SFTPに送信する場合は、次のコードを使用しています。スタンドアロンファイル転送用AS2クライアント
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のように転送する簡単な方法はありますか?