如何在 JAVA 中为 WSDL 中定义的 REST 生成 RESTful 客户端 [英] How to generate RESTful client in JAVA for REST defined in WSDL

查看:24
本文介绍了如何在 JAVA 中为 WSDL 中定义的 REST 生成 RESTful 客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道 WSDL 用于定义基于 SOAP 的 Web 服务,但在我在网上看到的大多数 WSDL 中,WSDL 中还定义了 RESTfulWeb 服务"-http:binding.

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.

为了为 SOAP 生成客户端,我使用了 JAX-WS 的 wsimport 工具(它还为 REST 生成客户端类,但它不起作用).

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).

那么问题来了,如何基于WSDL生成REST客户端呢?

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

推荐答案

我从未听说过有人使用 WSDL 来生成 REST 客户端.WADL 是,但不是 WSDL.

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

无论如何,为 REST 服务生成客户端是没有意义的.如果你认为你想这样做,那么你就错过了 REST 的好处,而试图遵循 REST 约束会让你做额外的工作.

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.

这篇关于如何在 JAVA 中为 WSDL 中定义的 REST 生成 RESTful 客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆