【问题标题】:MarshallingWebServiceOutboundGateway with JAXB marshaller throws error带有 JAXB 编组器的 MarshallingWebServiceOutboundGateway 引发错误
【发布时间】:2015-05-01 17:19:32
【问题描述】:

我正在使用 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-integration 框架以某种方式破坏了 JAXB 期望的响应类型,但我不知道如何解决这个问题。有人可以帮忙吗?

【问题讨论】:

    标签: java spring jaxb spring-integration


    【解决方案1】:

    这是我缺乏想法的一个例子。我需要在MarshallingWebServiceOutboundGateway 前面有一个转换器,以将来自entryPointChannelLinkedMultiValueMap 转换为JAXB 编组器所期望的对象。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-06-16
      • 2010-10-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-17
      • 1970-01-01
      相关资源
      最近更新 更多