简体   繁体   English

从目标响应中获取令牌并传递到 Mirth 中的新频道

[英]Get Token from destination response and pass to new Channel in Mirth

I've created a channel in Mirth which first calls authentication service and returns response.我在Mirth 中创建了一个通道,它首先调用身份验证服务并返回响应。 Source I've configured to HTTP Listener and in destination I've used HTTP Sender which calls a rest service for login and returns token as below.源我已配置为HTTP 侦听器,在目标中我使用了HTTP 发送器,它调用休息服务进行登录并返回令牌,如下所示。

{"token":"5912aa99-af21-5614-c232-d22be9e5c102","app":"TEST API Suite","expires":845,"userID":"ZCT06D123Cfk20oROB9x-bEXeY12oQGfack6dMMc-0o="} {"token":"5912aa99-af21-5614-c232-d22be9e5c102","app":"TEST API Suite","expires":845,"userID":"ZCT06D123Cfk20oROB9x-bEXeY12oMMGf0="

Question: From the response that I'm receiving from rest service , how do I extract the token part and then pass that token to another channel and use it for calling another service.问题:从我从 rest service 收到的响应中,我如何提取令牌部分,然后将该令牌传递给另一个通道并使用它来调用另一个服务。

Is there a way that I can set the token in a variable or global map in Destination1 and use that in Destination2 configuration?有没有办法可以在 Destination1 的变量或全局映射中设置令牌并在 Destination2 配置中使用它?

Please Help.请帮忙。 I'm a Newbie in Mirth.我是 Mirth 的新手。 Thanks.谢谢。

The following helped me and solved my issue.以下帮助我并解决了我的问题。 Add a post processor script as this in channel1 :channel1 中添加一个后处理器脚本:

var dest1 = responseMap.get("Destination 1");
var response123=dest1.getMessage();
var obj = JSON.parse(response123);
logger.info('token==='+obj.token);
router.routeMessage('newChannelName', obj.token);
return;

And then in newChannelName Channel preprocessor script, I was able to get this token as message.然后在newChannelName通道预处理器脚本中,我能够将此令牌作为消息获取。

logger.info('token: '+message);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM