Created
October 3, 2014 18:30
-
-
Save martinusadyh/b337e2f772d04f6151a2 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.util.logging.Level; | |
| import java.util.logging.Logger; | |
| import org.jpos.iso.BaseChannel; | |
| import org.jpos.iso.ISOException; | |
| import org.jpos.iso.ISOMsg; | |
| import org.jpos.iso.ISOPackager; | |
| import org.jpos.iso.ISORequestListener; | |
| import org.jpos.iso.ISOServer; | |
| import org.jpos.iso.ISOSource; | |
| import org.jpos.iso.ServerChannel; | |
| import org.jpos.iso.channel.ASCIIChannel; | |
| import org.jpos.iso.packager.GenericPackager; | |
| /** | |
| * | |
| * @author Martinus Ady H <mrt.itnewbies@gmail.com> | |
| */ | |
| public class JPosServer implements ISORequestListener { | |
| /** | |
| * @param args the command line arguments | |
| */ | |
| public static void main(String[] args) throws ISOException { | |
| String hostname = "localhost"; | |
| int portNumber = 12345; | |
| // membuat sebuah packager | |
| ISOPackager packager = new GenericPackager("packager/iso93ascii.xml"); | |
| // membuat channel | |
| ServerChannel channel = new ASCIIChannel(hostname, portNumber, packager); | |
| // membuat server | |
| ISOServer server = new ISOServer(portNumber, channel, null); | |
| server.addISORequestListener(new JPosServer()); | |
| new Thread(server).start(); | |
| System.out.println("Server siap menerima koneksi pada port [" + portNumber+"]"); | |
| } | |
| public boolean process(ISOSource isoSrc, ISOMsg isoMsg) { | |
| try { | |
| System.out.println("Server menerima koneksi dari ["+((BaseChannel)isoSrc).getSocket().getInetAddress().getHostAddress()+"]"); | |
| if (isoMsg.getMTI().equalsIgnoreCase("1800")) { | |
| acceptNetworkMsg(isoSrc, isoMsg); | |
| } | |
| } catch (IOException ex) { | |
| Logger.getLogger(JPosServer.class.getName()).log(Level.SEVERE, null, ex); | |
| } catch (ISOException ex) { | |
| Logger.getLogger(JPosServer.class.getName()).log(Level.SEVERE, null, ex); | |
| } | |
| return false; | |
| } | |
| private void acceptNetworkMsg(ISOSource isoSrc, ISOMsg isoMsg) throws ISOException, IOException { | |
| System.out.println("Accepting Network Management Request"); | |
| ISOMsg reply = (ISOMsg) isoMsg.clone(); | |
| reply.setMTI("1810"); | |
| reply.set(39, "00"); | |
| isoSrc.send(reply); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
mas mau tanya, setelah saya run JPosServer nya ada error ini
Server siap menerima koneksi pada port [12345] Exception in thread "Thread-0" java.lang.NoClassDefFoundError: org/osgi/framework/BundleException at org.jpos.util.Logger.log(Logger.java:73) at org.jpos.iso.ISOServer.run(ISOServer.java:533) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.ClassNotFoundException: org.osgi.framework.BundleException at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 3 more BUILD SUCCESSFUL (total time: 2 seconds)ini kenapa ya mas?
terima kasih