【问题标题】:Calling Camlet RESTLET Server with Apache HTTp Client使用 Apache HTTP 客户端调用 Camlet RESTLET 服务器
【发布时间】:2013-10-02 00:21:58
【问题描述】:

这个应该是微不足道的,但不知何故它不适合我。我正在尝试调用 Camel 上托管的 RESTLET 服务器。我让它与 Camel 客户端一起工作,但我试图让它与裸 Apache HTTP 客户端一起工作。 Camel的客户端如下:

   CamelContext context = new DefaultCamelContext();
   Map<String, Object> headers = new HashMap<String, Object>();
   context.createProducerTemplate().requestBodyAndHeaders("restlet:http://localhost:8086/Bookmarkee/boolean/V2?restletMethod=post", "Halleluia",headers);

我正在尝试使用的 HTTP 客户端是这样的:

        HttpPost httppost = new HttpPost("http://localhost:8086/Bookmarkee/boolean/V2?restletMethod=post");
        StringEntity e= new StringEntity("Halleluia",ContentType.create("text/plain", "UTF-8"));
        httppost.setEntity(e);
        CloseableHttpResponse response = httpclient.execute(httppost);

但是,在服务器上,servlet 引擎不会从流中读取响应。导致我的组件被传递一个输入流而不是一个字符串。

有什么线索吗?

【问题讨论】:

    标签: rest apache-camel restlet restlet-2.0


    【解决方案1】:

    当我的骆驼路线尝试处理来自服务器的空响应时遇到同样的问题(200 OK,Content-Length:0,Content-Type:application/json) 在我发现并修复了用于使用 http 组件请求的 URL 中的错误后修复

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-06-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-24
      • 1970-01-01
      相关资源
      最近更新 更多