Tuesday, September 13, 2016

ISO8583 [Inbound + Connector] Scenarios

In this blog, we will see how can we use both inbound and connector for different kind of scenarios. 
Check previous post for basic use-case of [ISO8583 Inbound + Connector]

First scenario satisfies the following flow.



  • Client send ISO8583 String messages to the inbound.
  • Inbound will consume the messages and inject it into the sequence in xml format.
  • Now Xml format ISO8583 Messages will be in the message context.
  • Instead of using Rest Client, Connector will get the message from the message context, then packed the fields to form ISO8583 String according to the field definitions and send it to the server.
  • Server will acknowledge the connector by changing the relevant response fields and response will be set into message context in xml format, Inbound get the response and packed the response again and acknowledge the client with the response.
In order to check with this scenario, you need to get the inbound org.wso2.carbon.inbound.iso8583-1.0.0.jar (click Download Streaming Connector), get the connector zip (click Download Connector) from the https://store.wso2.com/store/assets/esbconnector/ISO8583 or by building the source code (connector - https://github.com/wso2-extensions/esb-connector-iso8583/tree/org.wso2.carbon.connector.ISO8583-1.0.0 , inbound - https://github.com/wso2-extensions/esb-inbound-iso8583/tree/org.wso2.carbon.inbound.iso8583-1.0.0 ),  download the jpos-1.9.4.jar from the http://mvnrepository.com/artifact/org.jpos/jpos/1.9.4 , download jdom-1.1.3.jar from http://mvnrepository.com/artifact/org.jdom/jdom/1.1.3 and download commons-cli-1.3.1.jar from http://mvnrepository.com/artifact/commons-cli/commons-cli/1.3.1 . Then copy the jars to the <ESB_HOME>/repository/components/lib directory and copy the  jposdef.xml file into <ESB_HOME>. Do the Connector configurations and with ESB by following Using a Connector. The recommend ESB version is 4.9 and later .

Note :  Here the ISO8583 inbound will listening on port 5000, so client will connected to that port
            ISO8583 connector will connect with port 5010, and the server will listen on port 5010.
 
Sample Configuration 

Within the request sequence tag add the <ISO8583.init> element in your configuration and use </ISO8583.sendMessage> operation to send the message.

 <sequence name="request" onError="fault">
        <property expression="$body" name="body"/>
        <ISO8583.init>
            <serverHost>localhost</serverHost>
            <serverPort>5010</serverPort>
        </ISO8583.init>
        <ISO8583.sendMessage>
            <body>request</body>
        </ISO8583.sendMessage>
        <log level="full"/>
    </sequence> 


Then update the inbound endpoint as follows.

<inboundEndpoint
        class="org.wso2.carbon.inbound.iso8583.listening.ISO8583MessageConsumer"
        name="custom_listener" onError="fault" sequence="request" suspend="false">
        <parameters>
            <parameter name="sequential">true</parameter>
            <parameter name="inbound.behavior">listening</parameter>
            <parameter name="port">5000</parameter>
        </parameters>
  </inboundEndpoint> 



If you have successfully configured with this  ISO8583[Inbound + Connector], then you can see the following log in your console.

Inbound will consume the message which is send by the client 

INFO - LogMediator To: , MessageID: urn:uuid:6C838679BEE7DB646A1473682524513, Direction: request, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Body><ISOMessage><data><field id="0">0200</field><field id="3">568893</field><field id="4">000000020000</field><field id="7">0110563280</field><field id="11">456893</field><field id="44">DFGHT</field><field id="105">ABCDEFGHIJ 9871236548</field></data></ISOMessage> 

Connector get these fields from message context  and packed the message and send it to server . Server will acknowledge the connector with the string of IS08583 Message. The response will set into the message context as following and client will acknowledge via inbound with the same string of ISO8583 Messages.

<ISOMessage><data><field id="0">0210</field><field id="3">568893</field><field id="4">000000020000</field><field id="7">0110563280</field><field id="11">456893</field><field id="39">00</field><field id="44">DFGHT</field><field id="105">ABCDEFGHIJ 9871236548</field></data></ISOMessage></soapenv:Body></soapenv:Envelope>

In the second scenario, you can consider ISO8583 Inbound as a server and ISO8583 Connector as a client .
So, Here Connector (Client) will send String of ISO8583 Messages to Inbound (Server) and Inbound (Server) acknowledge the Connector (Client). 
  1. You can use Rest-Client to initiate the ISO8583 Messages in xml format.
  2. Then the connector will get the fields and packed as String of ISO8583 Message.
  3. Packed message will be sent to the Inbound (Since it is listen on same port).
  4. Inbound consume the String Message and inject the message into sequence in xml format and then acknowledge the connector with the string of ISO8583 Message by changing  relevant response fields.
  5. Acknowledgment will set into message context in xml format.    
 
Sample Configuration 
Since we consider the inbound as a server and connector as a client, we have to maintain the same port for inbound and connector configuration.
In order to check with this scenario, you have to do some minor changes in Inbound and its configuration as following. 
  <proxy name="ISO8583_Test" startOnLoad="true" trace="disable" transports="https http">
        <description/>
        <target>
            <inSequence>
                <ISO8583.init>
                    <serverHost>localhost</serverHost>
                    <serverPort>5000</serverPort>
                </ISO8583.init>
                <ISO8583.sendMessage/>
                <log level="full"/>
                <respond/>
            </inSequence>
            <outSequence>
                <log/>
                <send/>
            </outSequence>
        </target>
    </proxy>


 <sequence name="request" onError="fault">
        <log level="full"/>
    </sequence>


<inboundEndpoint
        class="org.wso2.carbon.inbound.iso8583.listening.ISO8583MessageConsumer"
        name="custom_listener" onError="fault" sequence="request" suspend="false">
        <parameters>
            <parameter name="sequential">true</parameter>
            <parameter name="inbound.behavior">listening</parameter>
            <parameter name="port">5000</parameter>
        </parameters>

</inboundEndpoint> 


  • Now, You have made the configuration,  In Rest-client set the header application/xml as Content-Type. POST the body in xml format and xml format message should be in the following structure.
 <ISOMessage>
      <data>
        <field id="0">0200</field>
        <field id="3">568893</field>
        <field id="4">000000020000</field>
        <field id="7">0110563280</field>
        <field id="11">456893</field>
        <field id="44">DFGHT</field>
        <field id="105">ABCDEFGHIJ 9871236548</field>
      </data>
</ISOMessage>


If all the  configurations are correct, then you can see the following log in your console.

Inbound will inject message into sequence

INFO - LogMediator To: , MessageID: urn:uuid:99A310AC504D6230D81473787521614, Direction: request, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Body><ISOMessage><data><field id="0">0200</field><field id="3">568893</field><field id="4">000000020000</field><field id="7">0110563280</field><field id="11">456893</field><field id="44">DFGHT</field><field id="105">ABCDEFGHIJ 9871236548</field></data></ISOMessage></soapenv:Body></soapenv:Envelope> 

Connector get acknowledgement and the response message will set in message context as following

<ISOMessage><data><field id="0">0210</field><field id="3">568893</field><field id="4">000000020000</field><field id="7">0110563280</field><field id="11">456893</field><field id="39">00</field><field id="44">DFGHT</field><field id="105">ABCDEFGHIJ 9871236548</field></data></ISOMessage>

1 comment:

  1. Thanks for this post. Since some days i couldn't find an post which explain so clear what you have done here. Stil thanks you!

    ReplyDelete