Created
October 3, 2014 18:32
-
-
Save martinusadyh/b13ba5a793511ab24931 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package id.web.martinusadyh.iso8583.jpos; | |
| import java.io.IOException; | |
| import java.text.SimpleDateFormat; | |
| import java.util.Date; | |
| import org.jpos.iso.ISOException; | |
| import org.jpos.iso.ISOMUX; | |
| import org.jpos.iso.ISOMsg; | |
| import org.jpos.iso.ISOPackager; | |
| import org.jpos.iso.ISORequest; | |
| import org.jpos.iso.channel.ASCIIChannel; | |
| import org.jpos.iso.packager.GenericPackager; | |
| /** | |
| * | |
| * @author Martinus Ady H <mrt.itnewbies@gmail.com> | |
| */ | |
| public class JPosClient { | |
| /** | |
| * @param args the command line arguments | |
| */ | |
| public static void main(String[] args) throws IOException, ISOException { | |
| String hostname = "localhost"; | |
| int portNumber = 12345; | |
| // membuat sebuah packager | |
| ISOPackager packager = new GenericPackager("packager/iso93ascii.xml"); | |
| // membuat channel | |
| ASCIIChannel channel = new ASCIIChannel(hostname, portNumber, packager); | |
| ISOMUX isoMux = new ISOMUX(channel) { | |
| @Override | |
| protected String getKey(ISOMsg m) throws ISOException { | |
| return super.getKey(m); | |
| } | |
| }; | |
| new Thread(isoMux).start(); | |
| // bikin network request | |
| ISOMsg networkReq = new ISOMsg(); | |
| networkReq.setMTI("1800"); | |
| networkReq.set(3, "123456"); | |
| networkReq.set(7, new SimpleDateFormat("yyyyMMdd").format(new Date())); | |
| networkReq.set(11, "000001"); | |
| networkReq.set(12, new SimpleDateFormat("HHmmss").format(new Date())); | |
| networkReq.set(13, new SimpleDateFormat("MMdd").format(new Date())); | |
| networkReq.set(48, "Tutorial ISO 8583 Dengan Java"); | |
| networkReq.set(70, "001"); | |
| ISORequest req = new ISORequest(networkReq); | |
| isoMux.queue(req); | |
| ISOMsg reply = req.getResponse(50*1000); | |
| if (reply != null) { | |
| System.out.println("Req ["+new String(networkReq.pack()) + "]"); | |
| System.out.println("Res ["+new String(reply.pack()) + "]"); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment