b090041-spcdeinfoservice-client-spring
A client library for accessing http://apis.data.go.kr/B090041/openapi/service/SpcdeInfoService.
See 특일정보(공공데이터포털) and/or 달력자료(한국천문연구원).
Verify
Verify with your own service key assigned by the service provider.
$ mvn -Pfailsafe -DservcieKey=... clean verify
Injection points
Common
Qualifier | Type | Notes |
---|---|---|
@SpcdeInfoServiceServiceKey |
String |
Provided by the service provider |
For SpcdeInfoServiceClient
with RestTemplate
Qualifier | Type | Notes |
---|---|---|
@SpcdeInfoServiceRestTemplate |
RestTemplate |
|
@SpcdeInfoServiceRestTemplateRootUri |
String |
Optional |
For SpcdeInfoServiceReactiveClient
with WebClient
Qualifier | Type | Notes |
---|---|---|
@SpcdeInfoServiceWebClient |
WebClient |
Usages
Expand the component-scanning path.
@SpringBootApplication(
scanBasePackageClasses = {
com.github.jinahya.datagokr.....client.NoOp.class,
MyApplication.class
}
)
class MyApplication {
}
Provide the service key assigned by the service provider. Note that the service provider may give you a URL-encoded value. You should use a URL-decoded value.
@SpcdeInfoServiceServiceKey
@Bean
String spcdeInfoServiceServiceKey(){
// The service key assigned by data.go.kr
// Might be already URL-encoded
// Use a URL-decoded value
// return "...%3D%3D"; (X)
// return "...=="; (O)
}
Using SpcdeInfoServiceClient
with RestTeamplate
Provide an instance of RestTemplate
qualified with @SpcdeInfoServiceRestTemplate
.
@SpcdeInfoServiceRestTemplate
@Bean
RestTemplate spcdeInfoServiceRestTemplate(){
return new RestTemplateBuilder()
...
.rootUri(AbstractSpcdeInfoServiceClient.BASE_URL_PRODUCTION)
.defaultHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_XML_VALUE)
.build();
}
Get @Autowired
with an instance of SpcdeInfoServiceClient
which is internally get autowired with the RestTemplate
instance.
@Autowired
private SpcdeInfoServiceClient client;
Using SpcdeInfoServiceReactiveClient
with WebClient
Provide an instance of WebClient
qualified with @SpcdeInfoServiceWebClient
.
@SpcdeInfoServiceWebClient
@Bean
WebClient spcdeInfoServiceWebClient(){
return WebClient.builder()
...
.baseUrl(AbstractSpcdeInfoServiceClient.BASE_URL_PRODUCTION)
.defaultHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_XML_VALUE)
.build();
}
Get @Autowired
with an instance of SpcdeInfoServiceReactiveClient
which is internally get autowired with the WebClient
instance.
@Autowired
private SpcdeInfoServiceReactiveClient client;