我有一个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
感谢您的帮助!
答案 0 :(得分:0)
具有相同名称的类是由2个WSDL生成的。它们之间存在冲突,因此需要JaxB绑定。