【问题标题】:How to handle more WSDL in one Jaxb2Marshaller?如何在一个 Jaxb2Marshaller 中处理更多 WSDL?
【发布时间】:2018-09-11 08:49:16
【问题描述】:

我有一个 Spring Boot Gradle 项目并使用 JAXB 编组器来编组和解组 XML 请求/响应。

它适用于一组包路径:

@Bean
public SoapClient client(Jaxb2Marshaller marshaller) throws Exception {
    SoapClient client = new SoapClient();
            client.setDefaultUri("http://localhost:8088");
    client.setMarshaller(marshaller);
            client.setUnmarshaller(marshaller);
    client.setMessageSender(httpComponentsMessageSender());
    return client;
}

@Bean
public Jaxb2Marshaller marshaller() throws Exception {
    Jaxb2Marshaller marshaller = new Jaxb2Marshaller();

            //works
            //marshaller.setContextPaths("generated.identity.wsdl");

            //works
            //marshaller.setContextPaths("generated.network.wsdl");

            //does not work
            marshaller.setContextPaths("generated.identity.wsdl","generated.network.wsdl");

    return marshaller;
}

使用更多参数运行后,我收到以下错误消息:

xycontroller.VerificationControllerTest > checkByToken FAILED
    java.lang.IllegalStateException
        Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException
            Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException
                Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException
                    Caused by: org.springframework.beans.factory.BeanCreationException
                        Caused by: org.springframework.beans.BeanInstantiationException
                            Caused by: org.springframework.oxm.UncategorizedMappingException
                                Caused by: com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException  

感谢您的帮助!

【问题讨论】:

  • 文档建议您需要指定classesToBeBoundpackagesToScan 属性,我建议将packagesToScan 设置为项目的根目录并重试。

标签: java spring spring-boot gradle jaxb


【解决方案1】:

同名的类是由 2 WSDL 生成的。它们存在冲突,因此需要 JaxB 绑定。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-02-06
    • 2020-02-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多