它仍然连接http,而不是https并失败:
org.apache.camel.http.common.HttpOperationFailedException:HTTP操作无法使用statusCode调用http://client.api.net/health:404
restConfiguration()
.component("restlet")
.host(Constant.CLIENT_URL)
.scheme("https").port(443)
.bindingMode(RestBindingMode.json);
答案 0 :(得分:1)
我已经使用xml来定义Camel Rest DSL,如果它可以帮助你检查它,我已经使用Postman rest客户端测试了这个函数,我的POST URL是http://localhost:8080/orders/postOrder并且JSON正文被发送到direct:start路线。您可以根据自己的用例定义自己的目的地
<bean id="sqlComponent" class="org.apache.camel.component.sql.SqlComponent">
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="RestletComponent" class="org.restlet.Component" />
<bean id="RestletComponentService" class="org.apache.camel.component.restlet.RestletComponent">
<constructor-arg index="0">
<ref bean="RestletComponent" />
</constructor-arg>
</bean>
<!--This is the post url -->
<!-- http://localhost:8080/orders/postOrder -->
<restConfiguration bindingMode="json" component="servlet" />
<rest path="/orders">
<post uri="/postOrder" consumes="application/json" produces="application/json">
<to uri="direct:start" />
</post>
</rest>
如果您使用maven
,请记住添加camel-restlet和camel-http依赖项