Add header above the field in JPOS

26 views
Skip to first unread message

Tony

unread,
Mar 28, 2017, 5:33:57 AM3/28/17
to jPOS Users


I still new to JPOS and need to have a results as below, where there have  a `<header></header>` before the `<field>`

    <log realm="server-channel-logger/127.0.0.1:34428" at="Tue Mar 28 15:11:33.377 MYT 2017" lifespan="569ms">
     
<receive>
       
<isomsg direction="incoming">
         
<header>
           
<field id="literal" value="ISO"/>
           
<field id = "proind" value ="00" />
           
<field id = "relNum" value ="xx" />
                        .....
         
</header>
         
<field id="0" value="0800"/>
         
<field id="7" value="03xxxxxxxx"/>
         
<field id="11" value="xxxxxx"/>
                        .......
       
</isomsg>
     
</receive>
   
</log>
   


This is what I have tried in Channel side

    public static void main(String[] args) throws Exception {
           
Logger logger = new Logger();
            logger
.addListener(new SimpleLogListener(System.out));
           
ISOChannel channel = new ASCIIChannel("localhost", 8000, new ISO87APackager());
           
((LogSource) channel).setLogger(logger, "test-channel");
           
try {
                channel
.connect();
               
ISOMsg m = new ISOMsg();
               
MEPSISOHeader header = new MEPSISOHeader(ISOUtil.hex2byte("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"));
                header
.setLiteral(MEPSISOHeader.LETERAL);
                header
.setProductIndicator(MEPSISOHeader.PROD_IND_MEPS_POS);
                header
.setReleaseNumber(MEPSISOHeader.RELEASE_NUMBER_E_POS_MSG);
                           
........
             
                header
.dump ("");
                m
.setMTI("0800");
                m
.set(7, "03xxxxxxxx");
                m
.set(11, "xxxxxx");
                     
....
                channel
.send(m);
               
ISOMsg incoming = channel.receive();
               
System.out.println(incoming.pack());
           
} catch (Exception e) {
               
System.out.println(e);
           
}
       
}



And this is the dump function

       
@Override
           
public void dump (String indent) {
               
if (header != null) {
                   
System.out.println (
                        indent
                     
+ "<header>\n"
                     
+ indent + " <field id=\"literal\" value=\""+ new String (header, 0, 3) + "\"/>\n"
                     
+ indent + " <field id=\"proInd\" value=\""+ new String(header, 3, 2) + "\"/>\n"
                     
+ indent + " <field id=\"relNum\" value=\""+ new String(header, 5, 2) + "\"/>\n"
                     
+ indent + "</header>"
                   
);  
               
}  
           
}



My result

     
 </connect>
   
</log>
   
<header>
     
<field id="literal" value="ISO"/>
     
<field id="proInd" value="00"/>
          .....
   
</header>
   
<log realm="test-channel/127.0.0.1:8000" at="Tue Mar 28 15:45:48.991 MYT 2017" lifespan="2ms">
     
<send>
       
<isomsg direction="outgoing">
         
<!-- org.jpos.iso.packager.ISO87APackager -->
         
<field id="0" value="0800"/>
         
<field id="7" value="03xxxxxxxx"/>
         
<field id="11" value="xxxxxx"/>
                  .....
       
</isomsg>
     
</send>
   
</log>
   
     


Is there a way I can move the `<log realm ...>` above the header ? I want the header part to be sent to the server too.

Tony

unread,
Mar 28, 2017, 5:57:41 AM3/28/17
to jPOS Users
Anyone can help ? Thanks

Andrés Alcarraz

unread,
Mar 28, 2017, 2:32:46 PM3/28/17
to jPOS Users
Your are never setting the header to the channel nor the message. you have to perform m.setHeader(header) before sending the message.

Although the header will be printed using its  dump method only if it's class implements the Loggeable interface.

hope this helps, 

best regards

Andrés

Andrés Alcarraz

2017-03-28 6:57 GMT-03:00 Tony <nick_s...@hotmail.com>:
Anyone can help ? Thanks

--
--
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 Google Groups "jPOS Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jpos-users+unsubscribe@googlegroups.com.
To post to this group, send email to jpos-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/6251cf52-9762-40dc-8b7d-c0c87baebc95%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Tony

unread,
Mar 28, 2017, 9:10:55 PM3/28/17
to jPOS Users
If I perform m.setHeader(header), I will not getting ISOxxxxxxx


在 2017年3月29日星期三 UTC+8上午2:32:46,Andrés Alcarraz写道:
Your are never setting the header to the channel nor the message. you have to perform m.setHeader(header) before sending the message.

Although the header will be printed using its  dump method only if it's class implements the Loggeable interface.

hope this helps, 

best regards

Andrés

Andrés Alcarraz

2017-03-28 6:57 GMT-03:00 Tony <nick_s...@hotmail.com>:
Anyone can help ? Thanks

--
--
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 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 post to this group, send email to jpos-...@googlegroups.com.

Andrés Alcarraz

unread,
Mar 28, 2017, 10:46:09 PM3/28/17
to jPOS Users
If you don't want to send that header I fail to understand what are you trying to achieve

Andrés Alcarraz

Enviado desde el móvil

To unsubscribe from this group and stop receiving emails from it, send an email to jpos-users+unsubscribe@googlegroups.com.

To post to this group, send email to jpos-...@googlegroups.com.

Mark Salter

unread,
Mar 30, 2017, 5:38:21 PM3/30/17
to jpos-...@googlegroups.com
On 28/03/17 10:33, Tony wrote:
>
> I still new to JPOS and ....

When are you going to stop using this as an excuse to rtfm? And ask
smart questions!

:-)

--
Mark

Reply all
Reply to author
Forward
0 new messages