Send/Receive ISO8583 Message using TCP/IP

8,500 views
Skip to first unread message

Shashikala G H

unread,
Sep 19, 2013, 6:58:39 AM9/19/13
to jpos-...@googlegroups.com
Here is the scenario :

Client Side : pack and send message to server using TCP/IP  
                   Receive the response message from server
                  unpack the Response message

ServerSide :   
                Receive the packed message sent by Client using TCP/IP
                pack and Send a Response message to Client


Server is able to receive the message sent by client and will be able to reach the code block to send response only when i comment the receive_PackedResponseData.readLine().getBytes()) in client code (But i'm not able to see the response on client side.). If its uncommented then  server  will not even reach the block of code to send response.
 I'm not able to understand whats wrong in it. Looking for your help.

Client Code :

                        BufferedOutputStream outStream = null;
BufferedReader receive_PackedResponseData = null;

  /**  Construct Request Message */
                        GenericPackager packager = new GenericPackager("basic.xml");
                        ISOMsg isoMsg = new ISOMsg();
isoMsg.setPackager(packager);
                        isoMsg.setMTI("0300");
//set all the required Data Elements

                       byte[]  send_PackedRequestData = isoMsg.pack();

                       Socket connection = new Socket("localhost", 8180);
if (connection.isConnected()) {
outStream = new BufferedOutputStream(
connection.getOutputStream());
outStream.write(send_PackedRequestData);
outStream.flush();
System.out.println("-----Request sent to server---");
System.out.println(ISOUtil.hexString(send_PackedRequestData));
}

/** Receive Response */

if (connection.isConnected()) {
receive_PackedResponseData = new BufferedReader(
new InputStreamReader(connection.getInputStream()));
System.out.println("-- RESPONSE recieved---");
System.out.println(receive_PackedResponseData);
// System.out.println("Response : "+ISOUtil.hexString(receive_PackedResponseData.readLine().getBytes()));
}

receive_PackedResponseData.close();
outStream.close();
connection.close();


Server Code :

               BufferedReader receive_PackedRequestData =null;
BufferedOutputStream outStream=null;
        
/** Establish connection */
ServerSocket Server = new ServerSocket(port);
System.out.println("TCPServer Waiting for client on port " + port);
Socket connection = Server.accept();


/** Receive Request */
if (connection.isConnected()) {
receive_PackedRequestData = new BufferedReader(new InputStreamReader(connection.getInputStream()));
fromclient = receive_PackedRequestData.readLine();
System.out.println("--- Request Received from Client--- ");
System.out.println( ISOUtil.hexString(fromclient.getBytes()));
}

/** Send the response */
if (connection.isConnected()) {
//Construct Response Message
isoMsg=new ISOMsg();
GenericPackager packager = new GenericPackager("basic.xml");
isoMsg.setPackager(packager);
isoMsg.setMTI("0310"); 
byte[] send_PackedResponseData = msg.pack();
outStream = new BufferedOutputStream(connection.getOutputStream());
outStream.write(send_PackedResponseData);
outStream.flush();
System.out.println("-------RESPONSE sent---------");
System.out.println(ISOUtil.hexString(send_PackedResponseData));
}
receive_PackedRequestData.close();
outStream.close();
connection.close();

Note : I'm running servercode and client code in seperate instance of eclipse on the same machine.









chhil

unread,
Sep 19, 2013, 7:29:05 AM9/19/13
to jpos-users
This is a java question and not a jpos question.
Please use the appropriate user group.

jPos uses channels and qservers for client server communication and its a matter of wiring them up correctly via some config files to get this for free.
For more details, search user group or get access to the programmers guide.

-chhil


--
--
jPOS is licensed under AGPL - free for community usage for your open-source project. Licenses are also available for commercial usage.
Please support jPOS, contact: sa...@jpos.org
 
You received this message because you are subscribed to the "jPOS Users" group.
Please see http://jpos.org/wiki/JPOS_Mailing_List_Readme_first
To post to this group, send email to jpos-...@googlegroups.com
To unsubscribe, send email to jpos-users+...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/jpos-users
 
---
You received this message because you are subscribed to the Google Groups "jPOS Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jpos-users+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Shashikala G H

unread,
Sep 19, 2013, 7:42:34 AM9/19/13
to jpos-...@googlegroups.com
I wanna use channels from JPOS indeed. I searched in  group but was not able to get enough information to startup. Looking for some more inputs like what config file we need to use.  How can i get qservers.

I'm just trying to understand the basics.

chhil

unread,
Sep 19, 2013, 7:54:44 AM9/19/13
to jpos-users
There a few pdf links in the user group.

http://jpos.org/doc/jPOS-EE.pdf

Search for client and server simulators in the pdf.

-chhil
Reply all
Reply to author
Forward
0 new messages