Spring Integration JavaDSL-在Enum.valueof()中使用的捕获头

Spring Integration JavaDSL-在Enum.valueof()中使用的捕获头,java,spring-integration,spring-ws,spring-dsl,Java,Spring Integration,Spring Ws,Spring Dsl,在Spring Integration Java DSL中使用WSInboundGateway时,是否有方法提取头(其值)并使用它来填充枚举 我已经尝试过,但SpEL没有评估: @Bean public IntegrationFlow aFlow() { return IntegrationFlows.from(aWSInboundGateway()) .transform( new GenericTransformer&l

在Spring Integration Java DSL中使用WSInboundGateway时,是否有方法提取头(其值)并使用它来填充枚举

我已经尝试过,但SpEL没有评估:

@Bean
public IntegrationFlow aFlow() {
    return IntegrationFlows.from(aWSInboundGateway())
            .transform(
                    new GenericTransformer<JAXBElement<SomeStruct>, SpecificEvent>() {
                        @Override
                        public SpecificEvent transform(JAXBElement<SomeStruct> payload) {
                            return new SpecificEvent(
                                    payload.getValue(), 
                                    Source.valueOf("headers['source']")
                            );
                        }
                    })
            .channel(someChannel())
            .get();
}
@Bean
公共集成流aFlow(){
返回IntegrationFlows.from(aWSInboundGateway())
.变换(
新型通用变压器(){
@凌驾
公共特定事件转换(JAXBElement有效负载){
返回新的特定事件(
payload.getValue(),
Source.valueOf(“headers['Source']”)
);
}
})
.channel(someChannel())
.get();
}

您的
通用变压器
impl必须如下所示:

new GenericTransformer<Message<JAXBElement<SomeStruct>>, SpecificEvent>() {
   @Override
   public SpecificEvent transform(Message<JAXBElement<SomeStruct>> message) {
        return new SpecificEvent(
                       message.getPayload().getValue(), 
                       Source.valueOf(message.getHeaders().get("source", String.class))
                       );
   }
}
新的通用变压器(){
@凌驾
公共特定事件转换(消息){
返回新的特定事件(
message.getPayload().getValue(),
Source.valueOf(message.getHeaders().get(“Source”,String.class))
);
}
}

从另一个角度看,您应该更多地阅读Spring集成,以了解SpEL在运行时是如何工作的,并认识到您的
Source.valueOf(“headers['Source'])
尝试从Spring集成的角度看是没有意义的。

您让我明白了:我确实是“游戏新手”。不可否认的是,即使在我缺乏经验的眼中,这一点至少可以说是尴尬的。谢谢你的提示;我会尽快处理它。我接受了你的答案,因为它非常适合我,并帮助我完成了我的项目。非常感谢。