Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 10 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(5)
JAX-RS (JSR311) 没有定义客户端 API,但大多数 JAX-RS 实现都有一个,例如 球衣,RESTeasy 或 Apache CXF。
Restlet 框架还具有客户端支持以及单独 HTTP客户端扩展。
由于这些是 REST 的专用库/框架,我建议您研究一下这些。
JAX-RS (JSR311) does not define a client API, but most JAX-RS implementations have one, like Jersey, RESTeasy or Apache CXF.
The Restlet framework also has client support as well as a seperate HTTP Client extension.
Since these are specialized libraries/frameworks for REST, I'd suggest you look into these.
您在评论中写道,您“希望有比 HttpClient 更高级别的东西”。 听起来 Restlet 会是完美的。 它提供了用于实现和使用 RESTful Web 应用程序的高级 API,以及用于较低级别实现的即插即用适配器。
例如,要使用 Restlet 1.1 将 Web 表单 POST 到资源:
如果需要在请求上设置更多选项,可以使用 Request 对象:
HTH!
You wrote in a comment that you were "hoping for something more high level" than HttpClient. It sounds like Restlet would be perfect. It provides a high-level API for implementing and using RESTful web applications, with plug-and-play adapters for the lower-level implementations.
For example, to POST a webform to a resource using Restlet 1.1:
If you need to set more options on the request, you can use a Request object:
HTH!
我建议您查看 WADL 项目。 WADL 之于 REST 就像 WSDL 之于 SOAP。
您首先需要使用 WADL 定义 REST 接口。 然后,您可以在其上运行 wadl2java 工具来生成 REST 调用的客户端存根。
一旦您拥有了 Web 服务的 WADL,您就可以实现一些工具来用它做其他事情,例如生成服务器端存根、生成文档等。
I suggest you take a look at the WADL project. WADL is to REST what WSDL is to SOAP.
You first need to define the REST interface using WADL. Then you can run the wadl2java tool on it to generate client stubs for the REST calls.
Once you have the WADL for a web service you can implement tools which do other things with it as well, e.g. generate server side stubs, generate documentation, etc.
HttpClient 主要来自 apache(请参阅 http://hc.apache. org/httpcomponents-client-ga/)。
HttpClient from apache mostly (see http://hc.apache.org/httpcomponents-client-ga/).
正如甘道夫和达雷尔·米勒所说,HttpClient。
您不需要从 HTTP 参数构建 XML。 XML 应该只是两个独立系统之间的接口。 使用 HttpClient 让您可以使用 Java 中的 String 值,无需从那里返回到 XML。
如果您此时要返回到 XML 以便发送到另一个系统,那么您应该考虑在与另一个系统通信之前将 HTTP 参数中的值移回您的域/应用程序逻辑中。 这对于保持应用程序逻辑与系统间通信的正确分离是必要的。
As Gandalf and Darrel Miller said, HttpClient.
You don't need to be constructing XML from HTTP params. XML should only be your interface between two separate systems. Using HttpClient puts you in Java with the String values at your disposal, goinn back into XML from there is needless.
If you are going back into XML at this point in order to send out to another system, you should be thinking about moving the values from the HTTP params back in to your domain/app logic before communicating with another system. This is necessary to keeps proper seperation of application logic from inter system communications.