我使用Spring启动来调用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;
}
Run Code Online (Sandbox Code Playgroud)
我打电话给服务如下:
OutputMessageType response = (OutputMessageType) getWebServiceTemplate().marshalSendAndReceive(
inputMessageType, new SoapActionCallback("http://Serviceuri"));
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
[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 …Run Code Online (Sandbox Code Playgroud) 我已经在我的项目中配置了Spring JMS。现在我的要求是,仅当属性文件中的标志处于 ON 时才读取消息。
在Spring中有哪些方法可以实现这一点?