0
点赞
收藏
分享

微信扫一扫

Biz-SIP业务中台案例实战(11)——ISO8583格式转换器(iso-8583)

Biz-SIP业务中台支持多种报文类型的格式转换器,包括XML、JSON、定长、有分隔符、ISO-8583等报文类型的解包和打包,格式转换器可以在Source模块和Sink服务中进行配置和使用,实现打包(平台标准报文格式转换成外部报文格式)和解包(外部报文格式转换成平台标准报文格式)。
iso-8583类型的格式转换器,能把Biz-SIP内部标准消息报文,根据配置打包成外部的ISO8583格式报文;同时也直接把外部的ISO8583格式报文,解包成Biz-SIP内部标准消息报文。
本节案例中是在Sink服务模块中,配置iso-8583格式转换器,以实现ISO8583格式报文(velocity-split)的打包和解包:
在这里插入图片描述

其中,App层是通过Sink透传App服务,直接让调用方通过OpenAPI接口调用Sink服务(iso-8583-sink),Sink服务会把平台内部标准格式(JSONObject对象,内部即JSON报文)进行打包成ISO8583格式报文,传给通讯连接器Connector,原包返回后再解包成平台内部标准格式,响应给调用方。

一、Sink层Sink服务的开发和配置

同样,在Biz-SIP配置目录的sink.yml中,配置对应的Sink服务:

- id: iso-8583-sink
  type: rest
  url: http://bizsip-sample-sink/iso-8583-sink
  converter:
    type: iso-8583
    destination-id: '00010344'
    source-id: '42430440'
    fields:
      - index: 2
        length: 19
        unfixed: 2
        name: accNo2
      - index: 3
        length: 6
        name: processingCode3
      - index: 4
        length: 12
        name: amt_trans4
      - index: 5
        length: 12
        name: amt_settlmt5
      - index: 6
        length: 12
        name: transactionAmount6
      - index: 7
        length: 10
        name: transmsn_date_time7
      - index: 9
        length: 8
        name: transmsn_date_time9
      - index: 10
        length: 8
        name: transmsn_date_time10
      - index: 11
        length: 6
        name: systemTraceAuditNumber11
      - index: 12
        length: 6
        name: time_local_trans12
      - index: 13
        length: 4
        name: date_local_trans13
      - index: 14
        length: 4
        name: date_expr14
      - index: 15
        length: 4
        name: date_settlmt15
      - index: 16
        length: 4
        name: date_conv16
      - index: 18
        length: 4
        name: mchnt_type18
      - index: 19
        length: 3
        name: mchnt_cntry_code19
      - index: 22
        length: 3
        name: pos_entry_mode_code22
      - index: 23
        length: 3
        name: card_seq_num23
      - index: 25
        length: 2
        name: pos_cond_code25
      - index: 26
        length: 2
        name: pos_pin_cap_code26
      - index: 28
        length: 9
        name: amt_fee28
      - index: 32
        length: 11
        unfixed: 2
        name: acq_inst_id_code32
      - index: 33
        length: 11
        unfixed: 2
        name: fwd_inst_id_code33
      - index: 35
        length: 37
        unfixed: 2
        name: track2_data35
      - index: 36
        length: 104
        unfixed: 3
        name: track3_data36
      - index: 37
        length: 12
        name: retrivl_ref_num37
      - index: 38
        length: 6
        name: authr_id_resp38
      - index: 39
        length: 2
        name: resp_code39
      - index: 41
        length: 8
        name: card_accptr_termnl_id41
      - index: 42
        length: 15
        name: card_accptr_id42
      - index: 43
        length: 40
        name: card_accptr_name_loc43
      - index: 44
        length: 25
        unfixed: 2
        name: addtnl_resp_code44
      - index: 45
        length: 76
        unfixed: 2
        name: track1_data45
      - index: 48
        length: 512
        unfixed: 3
        name: addtnl_data_private48
      - index: 49
        length: 3
        name: currcy_code_trans49
      - index: 50
        length: 3
        name: currcy_code_settlmt50
      - index: 51
        length: 3
        name: currcy_code_cdhldr_bil51
      - index: 52
        length: 8
        name: pin_data52
      - index: 53
        length: 16
        name: security_control_info53
      - index: 54
        length: 40
        unfixed: 3
        name: addtnl_amt54
      - index: 55
        length: 255
        unfixed: 3
        name: ICC_data55
      - index: 56
        length: 255
        unfixed: 3
        name: token_par56
      - index: 57
        length: 100
        unfixed: 3
        name: issr_addtnl_data57
      - index: 59
        length: 600
        unfixed: 3
        name: detai_inquiring59
      - index: 60
        length: 100
        unfixed: 3
        name: reserved60
      - index: 61
        length: 200
        unfixed: 3
        name: ch_auth_info61
      - index: 62
        length: 200
        unfixed: 3
        name: switching_data62
      - index: 63
        length: 512
        unfixed: 3
        name: fin_net_data63
      - index: 70
        length: 3
        name: net_mgr_info_code70
      - index: 90
        length: 42
        name: ori_data_element90
      - index: 96
        length: 8
        name: msg_security_code96
      - index: 100
        length: 11
        unfixed: 2
        name: rcvg_inst_id_code100
      - index: 102
        length: 28
        unfixed: 2
        name: acct_id_1_102
      - index: 103
        length: 28
        unfixed: 2
        name: acct_id_2_103
      - index: 104
        length: 512
        unfixed: 3
        name: trans_industry_app_inf104
      - index: 113
        length: 512
        unfixed: 3
        name: add_data113
      - index: 117
        length: 256
        unfixed: 3
        name: addtnl_data117
      - index: 121
        length: 100
        unfixed: 3
        name: national_sw_resved121
      - index: 122
        length: 100
        unfixed: 3
        name: acq_inst_resvd122
      - index: 123
        length: 100
        unfixed: 3
        name: issr_inst_resvd123
      - index: 125
        length: 256
        unfixed: 3
        name: addtnl_data125
      - index: 128
        length: 8
        name: msg_authn_code128
  connector:
    type: service
    class-name: com.bizmda.bizsip.sample.sink.service.EchoConnectorService

可以看到iso-8583-sink这个Sink服务,connector关联了能把请求报文直接原包响应返回的EchoConnectorService类。而格式转换器converter,则直接设置“type: iso-8583”,表示采用ISO8583格式转换器,作为当前Sink服务的格式转换器。
Sink服务的converter项下配置了destination-id和source-id参数,分别代表目的地址和源地址,fields下定义了ISO8583报文中各域的约定,index为域号,name为数据关联的域名,length为域长度,unfixed为变长位数。
这个Sink服务没有设置processor属性,即为缺省default类型,采用默认的缺省Sink服务流程来处理的,处理步骤依次为:

  1. 调用格式转换器converter对传入报文进行打包;
  2. 对上步打包后的报文作为调用请求报文,调用通讯适配器connector进行处理,并收到并返回响应报文;
  3. 调用格式转换器converter对响应报文进行解包,并返回解包后的报文。

最后,还需要在SampleSinkApplication的应用配置文件application-local.yml中,在bizsip.sink-id配置项中,增加iso-8583-sink以便启动Sink服务:

bizsip:
  config-path: /var/bizsip/config
  sink-id: hello-sink,echo-sink,simple-xml-sink,velocity-json-sink,velocity-xml-sink,fixed-length-sink,velocity-split-sink,iso-8583-sink

二、App层App服务的开发和配置

对于Sink透传App服务,只需要在app.yml中配置即可:

- app-service-id: /sink/iso-8583-sink
  type: sink-service
  sink-id: iso-8583-sink

可以看到在app.yml中,配置了App服务“/sink/iso-8583-sink”,类型为Sink透传App服务(sink-service),透传调用的Sink服务为“iso-8583-sink”。

三、启动应用进行测试

启动SampleSinkApplication、SampleAppApplication应用,通过OpenAPI接口进行测试:

$ curl -H "Content-Type:application/json" -H "Biz-Service-Id:/sink/iso-8583-sink" -X POST --data '{"msgType": "0800","reserved60": "000000000030","card_accptr_id42": "898411341310014","systemTraceAuditNumber11": "000001","switching_data62": "53657175656e6365204e6f3132333036303733373832323134","card_accptr_termnl_id41": "73782214","msgHead": "31323334353637383930313233343536373839303132333435363738393031323334353637383930313233343536","acct_id_1_102": "1234567890","fin_net_data63": "303031"}' http://localhost:8888/api|jq

{
  "code": 0,
  "message": "success",
  "extMessage": null,
  "appServiceId": "/sink/iso-8583-sink",
  "traceId": "9ffadf46d47849d2b353baec35d42ac7",
  "parentTraceId": null,
  "timestamp": 1647176027306,
  "data": {
    "msgType": "0800",
    "reserved60": "000000000030",
    "card_accptr_id42": "898411341310014",
    "systemTraceAuditNumber11": "000001",
    "switching_data62": "53657175656e6365204e6f3132333036303733373832323134",
    "card_accptr_termnl_id41": "73782214",
    "msgHead": "31323031383430303031303334342020203432343330343430202020393031323334353637383930313233343536",
    "acct_id_1_102": "1234567890",
    "fin_net_data63": "303031"
  }
}

EchoConnectorService打印日志:

收到报文:
====+ 01-02-03-04-05-06-07-08-09-10-11-12-13-14-15-16-17-18-19-20 + ====== ASCII  ====== +
0000: 31 32 30 31 38 34 30 30 30 31 30 33 34 34 20 20 20 34 32 34 | 12018400010344   424 |
0020: 33 30 34 34 30 20 20 20 39 30 31 32 33 34 35 36 37 38 39 30 | 30440   901234567890 |
0040: 31 32 33 34 35 36 30 38 30 30 80 20 00 00 00 C0 00 16 00 00 | 1234560800� ...�.... |
0060: 00 00 04 00 00 00 30 30 30 30 30 31 37 33 37 38 32 32 31 34 | ......00000173782214 |
0080: 38 39 38 34 31 31 33 34 31 33 31 30 30 31 34 30 31 32 30 30 | 89841134131001401200 |
0100: 30 30 30 30 30 30 30 30 33 30 30 35 30 35 33 36 35 37 31 37 | 00000000300505365717 |
0120: 35 36 35 36 65 36 33 36 35 32 30 34 65 36 66 33 31 33 32 33 | 5656e6365204e6f31323 |
0140: 33 33 30 33 36 33 30 33 37 33 33 33 37 33 38 33 32 33 32 33 | 33036303733373832323 |
0160: 31 33 34 30 30 36 33 30 33 30 33 31 31 30 31 32 33 34 35 36 | 13400630303110123456 |
0180: 37 38 39 30                                                 | 7890................ |
举报

相关推荐

0 条评论