带有 JAXB 编组器的 MarshallingWebServiceOutboundGateway 抛出错误
MarshallingWebServiceOutboundGateway with JAXB marshaller throws error
我正在使用 spring-integration 4.1.2-RELEASE,MarshallingWebServiceOutboundGateway
有点问题。我正在尝试对 SOAP Web 服务进行 SOAP 调用,使用 JAXB 生成 wsdl 的对象表示。
我的自动接线和流程如下所示:
@Autowired
MarshallingWebServiceOutboundGateway securityService;
@Autowired
HttpRequestExecutingMessageHandler documentService;
@Bean
IntegrationFlow getDocument() {
return IntegrationFlows.from("entryPointChannel")
.handle(securityService)
.handle(documentService)
.get();
}
问题出在 securityService
bean 上。这是定义:
@Value("${evry.services.security.endpoint}")
String securityEndpoint;
@Value("${org.apache.ws.security.crypto.merlin.keystore.alias}")
String user;
@Value("${org.apache.ws.security.crypto.merlin.keystore.password}")
String password;
@Bean
MarshallingWebServiceOutboundGateway securityService() {
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
marshaller.setContextPath("securityServices.wsdl");
MarshallingWebServiceOutboundGateway securityGateway = new MarshallingWebServiceOutboundGateway(
securityEndpoint, marshaller, marshaller
);
Wss4jSecurityInterceptor securityInterceptor = new Wss4jSecurityInterceptor();
try {
securityInterceptor.setSecurementSignatureCrypto(new CryptoFactoryBean().getObject());
} catch (Exception e) {
e.printStackTrace();
}
securityInterceptor.setSecurementActions("Timestamp Signature");
securityInterceptor.setSecurementSignatureKeyIdentifier("DirectReference");
securityInterceptor.setSecurementSignatureUser(user);
securityInterceptor.setSecurementPassword(password);
securityInterceptor.setSecurementTimeToLive(300000);
securityInterceptor.setTimestampPrecisionInMilliseconds(true);
securityGateway.setInterceptors(securityInterceptor);
return securityGateway;
}
调用时,这是(部分)错误输出:
javax.xml.bind.JAXBException: class org.springframework.util.LinkedMultiValueMap nor any of its super class is known to this context.
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getBeanInfo(JAXBContextImpl.java:567)
at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:467)
at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:308)
at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:236)
在我看来,spring-集成框架以某种方式破坏了 JAXB 期望的响应类型,但我不知道如何解决这个问题。有人可以帮忙吗?
这是我考虑不周的情况。我需要在 MarshallingWebServiceOutboundGateway
前面有一个转换器,以将来自 entryPointChannel
的 LinkedMultiValueMap
转换为 JAXB 编组器所期望的对象。
我正在使用 spring-integration 4.1.2-RELEASE,MarshallingWebServiceOutboundGateway
有点问题。我正在尝试对 SOAP Web 服务进行 SOAP 调用,使用 JAXB 生成 wsdl 的对象表示。
我的自动接线和流程如下所示:
@Autowired
MarshallingWebServiceOutboundGateway securityService;
@Autowired
HttpRequestExecutingMessageHandler documentService;
@Bean
IntegrationFlow getDocument() {
return IntegrationFlows.from("entryPointChannel")
.handle(securityService)
.handle(documentService)
.get();
}
问题出在 securityService
bean 上。这是定义:
@Value("${evry.services.security.endpoint}")
String securityEndpoint;
@Value("${org.apache.ws.security.crypto.merlin.keystore.alias}")
String user;
@Value("${org.apache.ws.security.crypto.merlin.keystore.password}")
String password;
@Bean
MarshallingWebServiceOutboundGateway securityService() {
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
marshaller.setContextPath("securityServices.wsdl");
MarshallingWebServiceOutboundGateway securityGateway = new MarshallingWebServiceOutboundGateway(
securityEndpoint, marshaller, marshaller
);
Wss4jSecurityInterceptor securityInterceptor = new Wss4jSecurityInterceptor();
try {
securityInterceptor.setSecurementSignatureCrypto(new CryptoFactoryBean().getObject());
} catch (Exception e) {
e.printStackTrace();
}
securityInterceptor.setSecurementActions("Timestamp Signature");
securityInterceptor.setSecurementSignatureKeyIdentifier("DirectReference");
securityInterceptor.setSecurementSignatureUser(user);
securityInterceptor.setSecurementPassword(password);
securityInterceptor.setSecurementTimeToLive(300000);
securityInterceptor.setTimestampPrecisionInMilliseconds(true);
securityGateway.setInterceptors(securityInterceptor);
return securityGateway;
}
调用时,这是(部分)错误输出:
javax.xml.bind.JAXBException: class org.springframework.util.LinkedMultiValueMap nor any of its super class is known to this context.
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getBeanInfo(JAXBContextImpl.java:567)
at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:467)
at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:308)
at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:236)
在我看来,spring-集成框架以某种方式破坏了 JAXB 期望的响应类型,但我不知道如何解决这个问题。有人可以帮忙吗?
这是我考虑不周的情况。我需要在 MarshallingWebServiceOutboundGateway
前面有一个转换器,以将来自 entryPointChannel
的 LinkedMultiValueMap
转换为 JAXB 编组器所期望的对象。