猿问

如何在一个 Jaxb2Marshaller 中处理更多 WSDL?

我有一个 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  

谢谢你的帮助!


噜噜哒
浏览 199回答 1
1回答

慕森王

同名的类由 2 WSDL 生成。它们是冲突的,因此需要 JaxB 绑定。
随时随地看视频慕课网APP

相关分类

Java
我要回答