我正在尝试在 Spring 集成中创建一个简单的 SOAP Web 服务代理。为此,我需要从调用我的服务的客户端传递到 SOAPAction 到我正在代理的服务。不幸的是,这个值似乎在转换为 Spring Integration Message 对象时丢失了。 Message 对象有一个有效负载和一个 header 。我期待在 header 中找到 SOAPAction(如“ws_soapAction”),但它不在那里。唯一的 header 是 replyChannel、errorChannel、id 和 timestamp。这些是标准的 Spring Integration header 。我可以通过对其进行硬编码来设置 ws_soapAction,但这会使服务的动态性大大降低。我已经尝试过 SOAP 1.1 和 SOAP 1.2。
这是应用程序:
@SpringBootApplication
public class OmgApplication {
public static void main(String[] args) {
SpringApplication.run(OmgApplication.class, args);
}
@Autowired
MarshallingWebServiceInboundGateway entryPoint;
@Autowired
MarshallingWebServiceOutboundGateway omgGateway;
@Bean
IntegrationFlow flow() {
return IntegrationFlows.from(entryPoint)
.handle(omgGateway)
.get();
}
}
还有网关:
@Bean
MarshallingWebServiceInboundGateway entryPoint() {
MarshallingWebServiceInboundGateway entryPoint = new MarshallingWebServiceInboundGateway(jaxb2Marshaller());
entryPoint.setHeaderMapper(new DefaultSoapHeaderMapper());
return entryPoint;
}
@Bean
MarshallingWebServiceOutboundGateway omgGateway() {
MarshallingWebServiceOutboundGateway omgGateway = new MarshallingWebServiceOutboundGateway(
"https://url.to.the/service", jaxb2Marshaller(), jaxb2Marshaller()
);
omgGateway.setHeaderMapper(new DefaultSoapHeaderMapper());
return omgGateway;
}
最佳答案
这将在 4.2 中可用。参见 this JIRA .
4.2 候选版本将于本周发布,实际发布时间为 9 月初。
目前在 4.2.0.BUILD-SNAPSHOT
中可用。
但是 JIRA 也有针对早期版本的解决方法。
关于java - SOAPAction 未在 Spring Integration 中传递,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31986389/