【问题标题】:Spring JAX-RS client - get response statusSpring JAX-RS 客户端 - 获取响应状态
【发布时间】:2017-04-23 09:37:00
【问题描述】:

我已经通过 spring 上下文注入了一个 JAX-RS 客户端 像这样:

<jaxrs:client id="restClient"
       address="http://localhost:${testutil.ports.BookServerRestSoap}/test/services/rest"
       serviceClass="org.apache.cxf.systest.jaxrs.BookStoreJaxrsJaxws">
</jaxrs:client>

在成功响应(200、202、204)的情况下如何访问响应状态?

【问题讨论】:

    标签: java spring rest jax-rs


    【解决方案1】:

    我遵循了这篇文章 https://java2blog.com/restful-web-services-jaxrs-crud-example/#comment-11493 中定义的相同步骤。我还没有更改本地文件中的任何文件。但最后,http://localhost:8080/JAXRSJsonCRUDExample/rest/countries 说 404 问题。 http://localhost:8080/JAXRSJsonCRUDExample/ 在浏览器中显示“Hello World”。

    【讨论】:

      【解决方案2】:

      尝试如下,

      org.apache.cxf.systest.jaxrs.BookStoreJaxrsJaxws proxy = ctx.getBean(org.apache.cxf.systest.jaxrs.BookStoreJaxrsJaxws.class);
      
      Response response = proxy.method();
      

      【讨论】:

      • 对于 json 提供者,我们必须使用那个org.codehaus.jackson.jaxrs.JacksonJsonProvider
      猜你喜欢
      • 2013-02-17
      • 2016-01-10
      • 2020-06-19
      • 1970-01-01
      • 2016-12-06
      • 1970-01-01
      • 2023-04-04
      • 2016-02-21
      • 1970-01-01
      相关资源
      最近更新 更多