简体   繁体   中英

Consuming RESTful API in Java, generating artifacts.

I am tasked with creating a layer in Java/Spring that consumes web services from a couple different providers. These services define specific request beans but the end points do not publish XSD information.

What would be the best way to generate the artifacts required to consume these services? It seems building our own request objects is not the best way of doing things.

REST services do not offer XSD as the WSDL of a traditional SOAP service. Some REST frameworks offer WADL, or the may user Swagger.io to describe the service, or expose documentation like Spring boots actuator /docs.

If there is no such documentation, and you can't get the source code for the system you are integrating with, I recommend that you build your own set of Java POJOs so you can interface with the service in a typed manner. I have done that for multiple systems that expose (online) documented REST services, but do not provide a set of DTO that you can use when consuming them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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