如何将 String 解析为 MbMessageAssembly?在Java计算节点IIB中

发布于 2025-01-11 19:51:39 字数 1894 浏览 0 评论 0原文

我对此很陌生,并且正在努力解决一个问题。 在 Java 计算节点中,通过 IIB,我检查一个字段是否有一个或多个值,并且对于每个附加值,我创建一个新的重复消息,除了值之外,这些附加值将被覆盖。 这按预期工作正常,请参见示例:

输入:...

</leg_flight_no><lineNumber>2</lineNumber><shipper_name>BMW AG</shipper_name> <shipper_reference_hu>1111111;22222222;333333333</shipper_reference_hu></root>

修改的消息 1:...

</leg_flight_no><lineNumber>2</lineNumber><shipper_name>BMW AG</shipper_name> <shipper_reference_hu>1111111</shipper_reference_hu></root>

修改的消息 2:..

</leg_flight_no><lineNumber>2</lineNumber><shipper_name>BMW AG</shipper_name> <shipper_reference_hu>22222222</shipper_reference_hu></root>

修改的消息 3:...

</leg_flight_no><lineNumber>2</lineNumber><shipper_name>BMW AG</shipper_name> <shipper_reference_hu>333333333</shipper_reference_hu></root>

但我正在努力从 Java 计算节点传播此消息。我知道我无法传播 String 类型的消息,因此我尝试将其解析为 MbMessageAssemble outAssemble。这是我的代码:

String newMessage = inData.replace(wholeValues, outData); // replace one value with another
                                
MbMessage outMessage = new MbMessage();
MbMessageAssembly outAssembly = new MbMessageAssembly(inAssembly, outMessage);
copyMessageHeaders(inMessage, outMessage);
MbElement outRoot = outMessage.getRootElement();
MbElement outParser = outRoot.createElementAsLastChild(MbBLOB.PARSER_NAME);
MbElement outBodyEl2 = outParser.createElementAsLastChild(MbElement.TYPE_NAME_VALUE, "BLOB", newMessage.getBytes());                                
alt.propagate(outAssembly);

但是这是传播一个空消息,因此 newMessage 不会解析为 outAssembly。有这方面经验的人可以帮我解决这个问题吗?

I am quite new to this, and I am struggling with one issue.
In Java Compute Node, through IIB, I am checking if one field has one or more values, and for each additional value I am creating a new duplicate message, except for value, these additional values are overriding.
This is working fine as a expect, see example:

Input :...

</leg_flight_no><lineNumber>2</lineNumber><shipper_name>BMW AG</shipper_name> <shipper_reference_hu>1111111;22222222;333333333</shipper_reference_hu></root>

Modified message 1:...

</leg_flight_no><lineNumber>2</lineNumber><shipper_name>BMW AG</shipper_name> <shipper_reference_hu>1111111</shipper_reference_hu></root>

Modified message 2:..

</leg_flight_no><lineNumber>2</lineNumber><shipper_name>BMW AG</shipper_name> <shipper_reference_hu>22222222</shipper_reference_hu></root>

Modified message3 :...

</leg_flight_no><lineNumber>2</lineNumber><shipper_name>BMW AG</shipper_name> <shipper_reference_hu>333333333</shipper_reference_hu></root>

But I am struggling to propagate this message out from the Java Compute node. I understand that I cant propagate messages of type String, so I am trying to parse this as a MbMessageAssemble outAssemble. This is my code:

String newMessage = inData.replace(wholeValues, outData); // replace one value with another
                                
MbMessage outMessage = new MbMessage();
MbMessageAssembly outAssembly = new MbMessageAssembly(inAssembly, outMessage);
copyMessageHeaders(inMessage, outMessage);
MbElement outRoot = outMessage.getRootElement();
MbElement outParser = outRoot.createElementAsLastChild(MbBLOB.PARSER_NAME);
MbElement outBodyEl2 = outParser.createElementAsLastChild(MbElement.TYPE_NAME_VALUE, "BLOB", newMessage.getBytes());                                
alt.propagate(outAssembly);

But this is propagate an empty message, so the newMessage is not parsed to outAssembly. Can anybody with this experience help me with this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

纵性 2025-01-18 19:51:39

我想通了。对于未来,这是你的答案

String newMessage = "this is some test";
MbMessage outMessage=new MbMessage();
outMessage.getRootElement().createElementAsLastChild(MbBLOB.PARSER_NAME).createElementAsLastChild(MbElement.TYPE_NAME_VALUE, "BLOB", newMessage.getBytes());
MbMessageAssembly outAssembly = new MbMessageAssembly(inAssembly, outMessage);
out.propagate(outAssembly);

I figured it out. For future, here is your answer

String newMessage = "this is some test";
MbMessage outMessage=new MbMessage();
outMessage.getRootElement().createElementAsLastChild(MbBLOB.PARSER_NAME).createElementAsLastChild(MbElement.TYPE_NAME_VALUE, "BLOB", newMessage.getBytes());
MbMessageAssembly outAssembly = new MbMessageAssembly(inAssembly, outMessage);
out.propagate(outAssembly);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文