简体   繁体   中英

How to consume Restful web services in spring rest

I would like to know how to consume Restful web service in spring mvc. I saw an example they user @RestController instead of using @Controller is the way to convert our mvc into restful service? and how data will be passed between service and client?.

What you want to know, is how a client can consume a webservice without knowing the APi contrat. Well you have many choice, for example, you can create your models (Requests,Responses) manually, depending on the JSON contract, for that your must show on the browser on another tool like postman, the request/response in JSon, after that you can use some other toot, to transfrom thoses json data to class, i generally use maven for that, but you can do it manually .

On the other hand, use an OPEN API like swagger, to describe your API, after you build your webservice Rest, you can generate a client which contains all data(requests,responses, operations GET, POST,...) for more information

Good Luck !!

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