启动ApplicationContext时出错。若要显示“条件”报告,请在启用“调试”的情况下重新运行应用程序。
2018-12-05 09:57:47 | ERROR | main | work.boot.SpringApplication:858 |应用程序运行失败
java.lang.IllegalStateException:未能执行CommandLineRunner
在org.springframework.boot.SpringApplication.callRunners上(SpringApplication.java:797)
在org.springframework.boot.SpringApplication.run上(SpringApplication.java:324)
在org.springframework.boot.SpringApplication.run上(SpringApplication.java:1260)
在org.springframework.boot.SpringApplication.run上(SpringApplication.java:1248)
在de.varengold.cdl.mvp.MvpApplication.main(MvpApplication.java:21)
内容编码必须设置为gzip
如何将内容编码设置为gzip?
这是我的代码:
@SpringBootApplication
@Slf4j
public class MvpApplication {
public static void main(String[] args) {
SpringApplication.run(MvpApplication.class, args);
}
@Bean
CommandLineRunner lookup(SOAPConnector soapConnector , Config config) {
return args -> {
SubmitDATTRA request = new SubmitDATTRA();
FileDataSource ds = new FileDataSource(config.getReportFilePath() );
request.setDatei(new DataHandler(ds));
SubmitDATTRAResponse response =(SubmitDATTRAResponse) soapConnector.callWebService(Config.TEST_URL, request);
};
}
}
内容类型是(sysout):application/octet stream。该文件是一个gzip文件。我想我已经接近解决方案了,但是我不知道如何告诉spring应该使用content Encoding=gzip
这是SOAPConnector
import javax.jws.WebService;
import org.springframework.ws.client.core.WebServiceTemplate;
import org.springframework.ws.client.core.support.WebServiceGatewaySupport;
public class SOAPConnector extends WebServiceGatewaySupport {
public Object callWebService(String url, Object request){
return getWebServiceTemplate().marshalSendAndReceive(url, request);
}
}
@Configuration
@Getter
public class Config {
public static final String PROD_URL = "https://portal.mvp.bafin.de:444/services/ws/a26mifir";
public static final String TEST_URL = "https://portal.mvp.bafin.de:444/services/ws/t_a26mifir";
@Value("${report.file.path}")
private String reportFilePath;
@Bean
public Jaxb2Marshaller marshaller() {
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
marshaller.setContextPath("de.acme.ws");
return marshaller;
}
@Bean
public SOAPConnector soapConnector(Jaxb2Marshaller marshaller) {
SOAPConnector client = new SOAPConnector();
client.setDefaultUri(TEST_URL);
client.setMarshaller(marshaller);
client.setUnmarshaller(marshaller);
return client;
}
}
我读到这篇文章,并从中得到灵感:
https://howtodoinjava.com/spring-boot/spring-soap-client-webservicetemplate/