[ ]
ZhouSa.com 响应处理插件
大多数应用场景需要对异常报文格式做转换或者映射, 响应处理插件主要提供对异常响应报文的转换处理功能, 异常的处理范围一般为网关内部产生的异常 响应处理插件一般在网关的响应链的最后执行. 网关的默认异常响应报文格式为:
{ "returnCode": { "type": "E", "message": "asdf", "code": "fasdg" } }
各字段配置如下:
配置示例:
response: available: true pipeType: direct preFilters: CheckPayloadEmptyFilter localRecognizers: - id: from_wlink_base matcher: '${msgFrom}->WLINK' type: date keyMap: resp_SysRtnTm: '${yyyy-MM-dd''T''HH:mm:ss}' values: - id: epcc_from_wlink_outbound_not_reached_response sort: 1 matcher: '${pathNo}->1285 && ${msgFrom}->WLINK && ${trxPhase}<>OUTBOUND_REACHED' type: default returnCodeKey: root.MsgBody.SysRtnInf typeKey: '' codeKey: SysRtnCd messageKey: SysRtnDesc replyKey: reply wrapReply: false ignoreReturnCode: false clearPayloadWhenFailed: false ignoreSuccessReturnCode: true extractReturnCode: false responseMappingCondition: failed defaultCodeMapping: {mappingCode: '${resp_CFlg}00099', msg: 系统异常} #如下配置, 假如异常响应报文的码值为 MSG_FMT_ERR, 则映射后的码值为 ${该配置为从上下文根据表达式获取值, 可不配} 00022,message为 请求报文格式有误 codeMapping: MSG_FMT_ERR: {mappingCode: '${resp_CFlg}00022', msg: 请求报文格式有误} FIELD_EMPTY: {mappingCode: '${resp_CFlg}00023', msg: 请求报文必填参数缺失} PARAM_ERR: {mappingCode: '${resp_CFlg}00024', msg: 请求报文的参数有误} VERSGN_FAIL: {mappingCode: '${resp_CFlg}00025', msg: 请求报文签名未通过验证} DYPT_FAIL: {mappingCode: '${resp_CFlg}00031', msg: 请求报文敏感字段解密失败} SYS_MAINT: {mappingCode: '${resp_CFlg}00003', msg: 银行系统临时维护} GTW0026: {mappingCode: '${resp_CFlg}00001', msg: 银行系统限制交易流量} GTW0012: {mappingCode: '${resp_CFlg}00001', msg: 银行系统限制交易流量} GTW0020: {mappingCode: '${resp_CFlg}00098', msg: 系统处理超时} GTW0000: {mappingCode: '00000000', msg: 系统处理完成} responseMapping: root.MsgHeader.MsgTp: '${resp_MsgTp}' root.MsgHeader.Drctn: '${resp_Drctn}' root.MsgBody.SysRtnInf.SysRtnTm: '${resp_SysRtnTm}' - id: epcc_from_wlink_outbound_reached_response sort: 1 matcher: '${pathNo}->1285 && ${msgFrom}->WLINK && ${trxPhase}->OUTBOUND_REACHED' type: default returnCodeKey: root.MsgBody.SysRtnInf typeKey: '' codeKey: SysRtnCd messageKey: SysRtnDesc replyKey: reply wrapReply: false ignoreReturnCode: false clearPayloadWhenFailed: false ignoreSuccessReturnCode: true extractReturnCode: false responseMappingCondition: failed defaultCodeMapping: {mappingCode: '${resp_CFlg}00098', msg: 系统异常} codeMapping: ENPT_FAIL: {mappingCode: '${resp_CFlg}00030', msg: 响应报文敏感字段加密失败} GENSGN_FAIL: {mappingCode: '${resp_CFlg}00026', msg: 响应报文生成签名失败} #这个应该抛不出来,加签失败会直接关连接 GTW0020: {mappingCode: '${resp_CFlg}00098', msg: 系统处理超时} GTW0000: {mappingCode: '00000000', msg: 系统处理完成} responseMapping: root.MsgHeader.MsgTp: '${resp_MsgTp}' root.MsgHeader.Drctn: '${resp_Drctn}' root.MsgBody.SysRtnInf.SysRtnTm: '${resp_SysRtnTm}'
还没有评论,来说两句吧...