如何使用 richHeaders 方法使用 java dsl 获取 xml 元素的 xpath
我正在尝试在 Spring 集成中使用 java dsl 获取 xml 元素的 xpth。我试图将元素名称放入丰富标题方法中,但它似乎不起作用。这是代码:
return IntegrationFlows.from(Http.inboundGateway("/person")
.requestMapping(m -> m.methods(HttpMethod.POST)
.consumes("application/xml")
.produces("application/json")
)
)
.enrichHeaders( h -> h.header("bsn","/BG:prsLa01/BG:body/BG:object/BG:bsn"))
.transform(new XmlToJsonTransformer())
.get();
i am trying to pick up an xpth of an xml element using java dsl in spring integration. I am trying to put the element name in the enrichHeaders method but it doesn't seem to be working. This is the code:
return IntegrationFlows.from(Http.inboundGateway("/person")
.requestMapping(m -> m.methods(HttpMethod.POST)
.consumes("application/xml")
.produces("application/json")
)
)
.enrichHeaders( h -> h.header("bsn","/BG:prsLa01/BG:body/BG:object/BG:bsn"))
.transform(new XmlToJsonTransformer())
.get();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
支持 xPath:
https://docs.spring.io/spring-integration/docs/5.2.5.RELEASE/reference/html/xml.html#xpath-spel-function
xpath SpEL功能
它可能如下所示:
另一种方法可能是
XPathExpressionEvaluatingHeaderValueMessageProcessor
:https://docs.spring.io/spring-integration/api/org/springframework/integration/xml/transformer/support/XPathExpressionEvaluatingHeaderValueMessageProcessor.html
使用示例:
There is support for xPath:
https://docs.spring.io/spring-integration/docs/5.2.5.RELEASE/reference/html/xml.html#xpath-spel-function
xpath SpEL Function
It could look like this:
Another way could be to
XPathExpressionEvaluatingHeaderValueMessageProcessor
:https://docs.spring.io/spring-integration/api/org/springframework/integration/xml/transformer/support/XPathExpressionEvaluatingHeaderValueMessageProcessor.html
Example of Usage: