【发布时间】:2016-07-05 10:07:39
【问题描述】:
我正在使用 Spring Boot 来调用 Web 服务。
我的配置类是:
@Configuration
public class ClientAppConfig {
@Bean
public Jaxb2Marshaller marshaller() {
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
marshaller.setPackagesToScan("com.client.stub");
return marshaller;
}
@Bean
public ARTestClient arTestClient(Jaxb2Marshaller marshaller) {
ARTestClient client = new ARTestClient();
client.setDefaultUri("uri");
client.setMarshaller(marshaller);
client.setUnmarshaller(marshaller);
return client;
}
我正在调用服务如下:
OutputMessageType response = (OutputMessageType) getWebServiceTemplate().marshalSendAndReceive(
inputMessageType, new SoapActionCallback("http://Serviceuri"));
我收到以下错误:
[2016-03-18 14:45:43.697] boot - 10272 ERROR [http-nio-8080-exec-1] --- [dispatcherServlet]: Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception
[Request processing failed; nested exception is java.lang.ClassCastException: javax.xml.bind.JAXBElement
cannot be cast to com.wfs.client.stub.ar.OutputMessageType] with root cause
如何解组来自 web 服务的输出?????? 我如何为响应设置解组器?
【问题讨论】:
标签: spring jaxb spring-boot unmarshalling