简体   繁体   English

在春季处理第三方服务的动态请求响应

[英]Handling dynamic request response of third party services in spring

We have our application written using Spring Boot. 我们有使用Spring Boot编写的应用程序。

We are integrating with various other third party services, such that request and response of each third party service is different. 我们正在与其他各种第三方服务集成在一起,因此每个第三方服务的请求和响应都是不同的。

Number of these third party services are dynamic and will keep on increasing with time. 这些第三方服务的数量是动态的,并且会随着时间的推移而不断增加。 We don't want to create a request and response class every time when a service is added and thinking to have a generic solution for same. 我们不想每次添加服务时都想创建一个请求和响应类,并且想为它提供通用的解决方案。 What we are thinking is if somehow request and response is made configurable (variable fields being read from xml, json file or from db) and on the fly java class can be created out for a service, so that next time a new service need to be integrated we will just configure request and response fields from a configuration source and there no need to touch code base. 我们在想的是,是否可以某种方式将请求和响应配置为可配置的(从xml,json文件或db中读取变量字段),并且可以为服务动态创建Java类,以便下次需要新服务时集成后,我们将只从配置源配置请求和响应字段,而无需接触代码库。

[Service can have xml or json based request response]. [服务可以具有基于xml或json的请求响应]。

Any lead on this can we really helpful. 在这方面的任何线索都可以对我们真正有所帮助。

Make your request response handling in DAO class and for test use different DAO injected using different Spring profiles as prod and test. 在DAO类中进行请求响应处理,并使用不同的Spring概要文件作为产品和测试来注入不同的DAO,以进行测试。

Other solution is using mock DAO using mockito for example that will just return your expected response 其他解决方案是使用模拟DAO(例如,使用Mockito),它将仅返回您的预期响应

我记得在我们的项目中创建了一些eclipse插件就完成了这种事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM