【发布时间】:2020-02-25 08:01:01
【问题描述】:
我正在实现一个将使用 RESTful Web 服务公开的应用程序。此应用程序将首先使用 RESTful Web 服务来获取 JSON 文件,并将此 JSON 文件返回给请求者(将使用我的服务的应用程序)。我在使用网络服务时遇到问题。
错误:
org.apache.camel.component.restlet.RestletOperationException: Restlet 操作调用 https:// 失败 statusCode: 1001 /n responseBody:HTTPS/1.1 - 通信错误 (1001) - 连接器未能完成与服务器的通信
在 org.apache.camel.component.restlet.RestletProducer.populateRestletProducerException(RestletProducer.java:233)
代码:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<camelContext id="camelcontext" xmlns="http://camel.apache.org/schema/spring">
<restConfiguration component="restlet" port="9091"/>
<rest path="/say">
<get uri="/hello" consumes="application/json" produces="application/json">
<to uri="direct:hello" />
</get>
</rest>
<route>
<from uri="direct:hello"/>
<to uri="restlet:https:// <--URL--> ?restletMethod=POST" />
</route>
</camelContext>
</beans>
【问题讨论】:
-
您是否一直在使用 Restlet 组件? Camel 3.x 已弃用 Restlet,因此您最好使用另一个组件,例如
servlet(用于提供 REST 服务)和http(用于使用外部服务)。
标签: rest apache-camel restlet