简体   繁体   中英

How to handle more WSDL in one Jaxb2Marshaller?

I have a Spring boot Gradle project and use a JAXB marshaller to marshall and unmarshall the XML requests/responses.

It works properly with one set package path:

@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;
}

after running with more parameters i get the following error message:

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  

Thanks for your help!

Classes with the same name were generated by the 2 WSDL. They were conflicted, so JaxB binding was needed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM