MarshallingWebServiceOutboundGateway与JAXB marshaller抛出错误

时间:2015-05-01 17:19:32

标签: java spring jaxb spring-integration

我正在使用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)

在我看来,弹簧集成框架在某种程度上破坏了JAXB期望的响应类型,但我无法弄清楚如何解决这个问题。有人可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

这是我个人缺乏思考的一个案例。我需要在MarshallingWebServiceOutboundGateway前面的变换器将LinkedMultiValueMapentryPointChannel转换为JAXB编组所期望的对象。