--
--
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
Join us in IRC at http://webchat.freenode.net/?channels=jpos
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/11feabf3-d655-4f0f-830e-b7fcfcebd6d1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
import java.io.IOException;
import org.jpos.iso.ISOChannel;
import org.jpos.iso.ISOException;
import org.jpos.iso.ISOMsg;
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;
import org.jpos.util.Logger;
import org.jpos.util.SimpleLogListener;
import org.jpos.util.ThreadPool;
public class Test {
public static void main(String[] args) throws IOException, ISOException {
Logger l = new Logger();
l.addListener(new SimpleLogListener());
GenericPackager serverPkg = new GenericPackager(
"C:\\temp\\iso93asciiB-custom.xml");
serverPkg.setLogger(l, "Server"); // So that the output can be differentiated based on realm
GenericPackager clientPkg = new GenericPackager(
"C:\\temp\\iso93asciiB-custom.xml");
clientPkg.setLogger(l, "Client");// So that the output can be differentiated based on realm
// Simulate a server and listen on a port
ISOChannel serverChannel = new ASCIIChannel(serverPkg);
((ASCIIChannel) serverChannel).setHeader("ISO70100000");
// AN equivalent in your channel adaptor deploy file would be
// <channel class="org.jpos.iso.channel.ASCIIChannel"
// packager="org.jpos.iso.packager.GenericPackager"
// header="ISO70100000"> .....
// This is evident from the ChanelAdaptor code
// QFactory.invoke (channel, "setHeader", e.getAttributeValue ("header"));
((ASCIIChannel) serverChannel).setLogger(l, "server");
ISOServer server = new ISOServer(7654, (ServerChannel) serverChannel,
new ThreadPool(10, 100, "serverListeningThread"));
server.addISORequestListener(new ISORequestListener() {
// If the client sends a message, the server will respond with and approval if its a request message
@Override
public boolean process(ISOSource source, ISOMsg msg) {
try {
if (!msg.isRequest()) {
msg.setResponseMTI();
msg.set(39, "000");
source.send(msg);
}
}
catch (ISOException | IOException ex) {
}
return true;
}
});
Thread serverThread = new Thread(server);
serverThread.start(); // beyond this point the server is listening for a client connection
ASCIIChannel clientChannel = new ASCIIChannel("127.0.0.1", 7654, clientPkg);
clientChannel.setHeader("ISO70100000"); //Similar to server, you can configure the constant in your deploy file
clientChannel.setLogger(l, "client");
clientChannel.connect(); // connect to server, it will be seen in the output console
ISOChannel connectChannel = server.getLastConnectedISOChannel();// Since server can have multiple connections,
// we get the last one that connected to it.
ISOMsg serverInitiatedRequest = new ISOMsg();
serverInitiatedRequest.set(0, "1804");
serverInitiatedRequest.set(7, "1607161705");
serverInitiatedRequest.set(11, "888402");
serverInitiatedRequest.set(12, "160716170549");
serverInitiatedRequest.set(24, "803");
serverInitiatedRequest.set(25, "0000");
serverInitiatedRequest.set(33, "101010");
serverInitiatedRequest.set(37, "619817888402");
connectChannel.send(serverInitiatedRequest); // use the last one connected to send a request message to the client.
ISOMsg receivedRequest = clientChannel.receive();// receive the serers request message at the client
ISOMsg clientResponse = (ISOMsg) receivedRequest.clone();
clientResponse.setResponseMTI();
clientResponse.set(39, "000");
clientChannel.send(clientResponse); // send the response to server
}
}
Output
<log realm="client/127.0.0.1:7654" at="Sun Jul 17 12:31:55 IST 2016.764" lifespan="33ms">
<connect>
127.0.0.1:7654
</connect>
</log>
<log realm="Server" at="Sun Jul 17 12:31:55 IST 2016.784" lifespan="4ms">
<pack>
31383034023001808800000031363037313631373035383838343032313630373136313730353439383033303030303036313031303130363139383137383838343032
</pack>
</log>
<log realm="server/127.0.0.1:10614" at="Sun Jul 17 12:31:55 IST 2016.785" lifespan="7ms">
<send>
<isomsg direction="outgoing">
<!-- org.jpos.iso.packager.GenericPackager[C:\temp\iso93asciiB-custom.xml] -->
<field id="0" value="1804"/>
<field id="7" value="1607161705"/>
<field id="11" value="888402"/>
<field id="12" value="160716170549"/>
<field id="24" value="803"/>
<field id="25" value="0000"/>
<field id="33" value="101010"/>
<field id="37" value="619817888402"/>
</isomsg>
</send>
</log>
<log realm="Client" at="Sun Jul 17 12:31:55 IST 2016.787" lifespan="1ms">
<unpack>
31383034023001808800000031363037313631373035383838343032313630373136313730353439383033303030303036313031303130363139383137383838343032
<bitmap>{7, 11, 12, 24, 25, 33, 37}</bitmap>
<unpack fld="7" packager="org.jpos.iso.IFA_NUMERIC">
<value>1607161705</value>
</unpack>
<unpack fld="11" packager="org.jpos.iso.IFA_NUMERIC">
<value>888402</value>
</unpack>
<unpack fld="12" packager="org.jpos.iso.IFA_NUMERIC">
<value>160716170549</value>
</unpack>
<unpack fld="24" packager="org.jpos.iso.IFA_NUMERIC">
<value>803</value>
</unpack>
<unpack fld="25" packager="org.jpos.iso.IFA_NUMERIC">
<value>0000</value>
</unpack>
<unpack fld="33" packager="org.jpos.iso.IFA_LLNUM">
<value>101010</value>
</unpack>
<unpack fld="37" packager="org.jpos.iso.IF_CHAR">
<value>619817888402</value>
</unpack>
</unpack>
</log>
<log realm="client/127.0.0.1:7654" at="Sun Jul 17 12:31:55 IST 2016.789" lifespan="4ms">
<receive>
<isomsg direction="incoming">
<!-- org.jpos.iso.packager.GenericPackager[C:\temp\iso93asciiB-custom.xml] -->
<header>49534F3730313030303030</header>
<field id="0" value="1804"/>
<field id="7" value="1607161705"/>
<field id="11" value="888402"/>
<field id="12" value="160716170549"/>
<field id="24" value="803"/>
<field id="25" value="0000"/>
<field id="33" value="101010"/>
<field id="37" value="619817888402"/>
</isomsg>
</receive>
</log>
<log realm="Client" at="Sun Jul 17 12:31:55 IST 2016.791">
<pack>
31383134023001808A00000031363037313631373035383838343032313630373136313730353439383033303030303036313031303130363139383137383838343032303030
</pack>
</log>
<log realm="Server" at="Sun Jul 17 12:31:55 IST 2016.791">
<unpack>
31383134023001808A00000031363037313631373035383838343032313630373136313730353439383033303030303036313031303130363139383137383838343032303030
<bitmap>{7, 11, 12, 24, 25, 33, 37, 39}</bitmap>
<unpack fld="7" packager="org.jpos.iso.IFA_NUMERIC">
<value>1607161705</value>
</unpack>
<unpack fld="11" packager="org.jpos.iso.IFA_NUMERIC">
<value>888402</value>
</unpack>
<unpack fld="12" packager="org.jpos.iso.IFA_NUMERIC">
<value>160716170549</value>
</unpack>
<unpack fld="24" packager="org.jpos.iso.IFA_NUMERIC">
<value>803</value>
</unpack>
<unpack fld="25" packager="org.jpos.iso.IFA_NUMERIC">
<value>0000</value>
</unpack>
<unpack fld="33" packager="org.jpos.iso.IFA_LLNUM">
<value>101010</value>
</unpack>
<unpack fld="37" packager="org.jpos.iso.IF_CHAR">
<value>619817888402</value>
</unpack>
<unpack fld="39" packager="org.jpos.iso.IFA_NUMERIC">
<value>000</value>
</unpack>
</unpack>
</log>
<log realm="server/127.0.0.1:10614" at="Sun Jul 17 12:31:55 IST 2016.792" lifespan="26ms">
<receive>
<isomsg direction="incoming">
<!-- org.jpos.iso.packager.GenericPackager[C:\temp\iso93asciiB-custom.xml] -->
<header>49534F3730313030303030</header>
<field id="0" value="1814"/>
<field id="7" value="1607161705"/>
<field id="11" value="888402"/>
<field id="12" value="160716170549"/>
<field id="24" value="803"/>
<field id="25" value="0000"/>
<field id="33" value="101010"/>
<field id="37" value="619817888402"/>
<field id="39" value="000"/>
</isomsg>
</receive>
</log>
<log realm="client/127.0.0.1:7654" at="Sun Jul 17 12:31:55 IST 2016.793" lifespan="3ms">
<send>
<isomsg direction="outgoing">
<!-- org.jpos.iso.packager.GenericPackager[C:\temp\iso93asciiB-custom.xml] -->
<header>49534F3730313030303030</header>
<field id="0" value="1814"/>
<field id="7" value="1607161705"/>
<field id="11" value="888402"/>
<field id="12" value="160716170549"/>
<field id="24" value="803"/>
<field id="25" value="0000"/>
<field id="33" value="101010"/>
<field id="37" value="619817888402"/>
<field id="39" value="000"/>
</isomsg>
</send>
</log>
I have the web application "A", from where I try to initiate 1804 request, this hits the gatewayserver (xxx.xxx.xxx.xx/ xxxx). We have deployed the jPOS tgz on the gatewayserver, inside the jPOS application (channel- adapter), i mention the ip address/port (yyy.yyy.yyyy.yy/yyyy) of the switch to which it has to connect. we are getting two responses from the switch (1814 and 1804). for the 1804 that I receive, I should be able to reply with response.But I could not achieve this.
To tell all my attempts to do it, I have modified the code in application "A" .if(respMti !=null && respMti.equals("1804")){HttpClient clientTwo = HttpClients.createDefault();HttpPost postRequestTwo = new HttpPost("http://xxx.xxx.xxx.xx:xxxx/abc");ByteArrayEntity entityTwo = new ByteArrayEntity(formMessageTwo());postRequestTwo.setEntity(entityTwo);try {HttpResponse responseTwo = clientTwo.execute(postRequestTwo);if(responseTwo==null){System.out.println("Successfully sent 1814 response and no further request from switch is received");}else{System.out.println("Further request from switch is received. Please check with switch");}} catch (ClientProtocolException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();}
If I send 1804 request to switch, I receive 1814 from switch -> jPOS -> application "A". And we are able to use the response in application "A".this way we get the response from the jPOS to web application.
In the second request from switch, switch sends 1804 request to jPOS. But for that request, my custom channel has to be modified to handle it.How should I modify the jPOS application such that it receives the 1804 response and it should send back the 1814.Hope I am clear. I am trying to give more explanation, so you can tell me what to do exactly.Please let me know if you need any further information
--
--
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
Join us in IRC at http://webchat.freenode.net/?channels=jpos
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/79fd7818-6aca-4c0f-bea1-b40f4d042fb7%40googlegroups.com.