How to generate RESTful client in JAVA for REST de

2019-01-11 21:38发布

问题:

I know that WSDL is for defining SOAP based web services but in most of the WSDLs I saw on net, in the WSDL is defined also RESTful "web service"-http:binding.

To generate client for the SOAP I used wsimport tool from JAX-WS (it also generates client classes for the REST but it doesnt work).

So the question is, how to generate REST client based on the WSDL?

回答1:

I've never heard of anyone using WSDL for generating REST clients. WADL yes, but not WSDL.

Anyway, generating clients for REST services does not make sense. If you think you want to do that then you are missing the benefits of REST and trying to follow the REST constraints is going to make you do extra work for nothing.



回答2:

Actually you can auto-generate a SOAP like stub for JAX-RS but it uses WADL which I believe is a WSDL variant.

Apache CXF does this and if that doesn't work for you it will also automatically create SOAP endpoints and SOAP clients.



回答3:

You can use RestDescribe to generate and compile WSDL, you can generate clients in php, ruby, python, java and C# using this. It generates clean code and there is a good change that you have to tweak it a bit after code generation, you can find good documentation and underlying thoughts behind the tool here.

There are few interesting and useful WADL tools mentioned on wintermute.



回答4:

IBM Developer network: WSDL2 can describe REST services.

I think in programmers mainstream is holy war SOAP (classic) - REST services. Nobody want this war, these conceptions can coexist - i see this is opinion not only from my and few people, but has grooving support in standards.