如何使用camel restlet

时间:2017-03-07 12:02:33

标签: java rest apache-camel rest-client

嗨大家目前我正在开发一个基于驼峰和java的项目。有一项要求可能会将 http 更改为 https 。 经过大量研究后,我能够将 restlet 暴露在 https 中。 但是当我试图从restclient点击url时,我没有得到任何响应,甚至没有错误。 当我在寻找开放端口时,我可以在那里找到我的端口。 我正在发送我的代码和日志以及我的代码。 请有人帮我解决这个问题。

生成日志

Mar 07, 2017 5:35:51 PM org.restlet.engine.connector.NetServerHelper start
INFO: Starting the internal [HTTPS/1.1] server on port 8060
[pache.camel.spring.Main.main()] RestletComponent               DEBUG Added method based router: org.apache.camel.component.restlet.MethodBasedRouter@7d6a41fe
[pache.camel.spring.Main.main()] RestletComponent               DEBUG Attached restlet uriPattern: /jsonRestlet method: POST
[pache.camel.spring.Main.main()] RestletComponent               DEBUG Attached methodRouter uriPattern: /jsonRestlet
[pache.camel.spring.Main.main()] RestletComponent               DEBUG Started methodRouter uriPattern: /jsonRestlet
[pache.camel.spring.Main.main()] SpringCamelContext             INFO  Route: route1 started and consuming from: Endpoint[https://localhost:8060/jsonRestlet]
[pache.camel.spring.Main.main()] ultManagementLifecycleStrategy DEBUG Load performance statistics disabled
[pache.camel.spring.Main.main()] SpringCamelContext             INFO  Total 1 routes, of which 1 are started.
[pache.camel.spring.Main.main()] SpringCamelContext             INFO  Apache Camel 2.17.2 (CamelContext: camel-1) started in 1.302 seconds
[pache.camel.spring.Main.main()] MainSupport                    DEBUG Starting Spring ApplicationContext: org.springframework.context.support.ClassPathXmlApplicationContext@77575e6a
[pache.camel.spring.Main.main()] DefaultListableBeanFactory     DEBUG Returning cached instance of singleton bean 'lifecycleProcessor'
[pache.camel.spring.Main.main()] ClassPathXmlApplicationContext DEBUG Publishing event in org.springframework.context.support.ClassPathXmlApplicationContext@77575e6a: org.springframework.context.event.ContextStartedEvent[source=org.springframework.context.support.ClassPathXmlApplicationContext@77575e6a: startup date [Tue Mar 07 17:35:49 IST 2017]; root of context hierarchy]
[pache.camel.spring.Main.main()] DefaultListableBeanFactory     DEBUG Returning cached instance of singleton bean 'camel-1'
[pache.camel.spring.Main.main()] SpringCamelContext             DEBUG onApplicationEvent: org.springframework.context.event.ContextStartedEvent[source=org.springframework.context.support.ClassPathXmlApplicationContext@77575e6a: startup date [Tue Mar 07 17:35:49 IST 2017]; root of context hierarchy]
[pache.camel.spring.Main.main()] DefaultListableBeanFactory     DEBUG Returning cached instance of singleton bean 'camel-1'

我的要求

URL:: https://localhost:8060/jsonRestlet
Request body::{"name":"mdnoorshid"}
<?xml version="1.0" encoding="UTF-8"?>
<!-- Configures the Camel Context -->

<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camel="http://camel.apache.org/schema/spring"
	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">

	<camel:sslContextParameters id="mySslContext">
		<camel:keyManagers keyPassword="bizruntime">
			<camel:keyStore resource="C:\\Users\\deepalisingh\\Desktop\\keystore.jks"
				password="bizruntime" />
		</camel:keyManagers>
		<camel:serverParameters clientAuthentication="WANT" />
	</camel:sslContextParameters>
    <bean id="sendPOST" class="com.bizruntime.CamelRestletHTTPS.HTTPSsendPost"></bean>

	<camelContext xmlns="http://camel.apache.org/schema/spring">
		<route>
			<from uri="restlet:https://localhost:8060/jsonRestlet?restletMethod=POST&amp;sslContextParameters=#mySslContext"/>
			<to uri="bean:sendPOST?method=sendPost" />
		</route>
	</camelContext>

</beans>

1 个答案:

答案 0 :(得分:0)

使用当前配置。
您必须在客户端中导入ssl-certificates 例如,您可以参考@kellen回答,如何使用Chrome .. here