使用jboss fuse消费第三方restful webservices的最佳方法

时间:2017-01-12 04:15:31

标签: rest apache-camel cxf restlet jbossfuse

我正在使用JBoss FUSE进行集成。我是新手。我想使用/调用第三方restful webservices。请任何人都能告诉我创建端点的最佳方法(如cxf,restlet等)。

此外,如果有任何有效的端到端示例,那将会有很大的帮助。

提前致谢。

2 个答案:

答案 0 :(得分:1)

最后,我可以在下方拨打休息服务是我的代码:

<?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://camel.apache.org/schema/spring          http://camel.apache.org/schema/spring/camel-spring.xsd         http://www.springframework.org/schema/beans          http://www.springframework.org/schema/beans/spring-beans.xsd         http://www.springframework.org/schema/context          http://www.springframework.org/schema/context/spring-context.xsd">
    <bean class="org.apache.activemq.camel.component.ActiveMQComponent" id="activemq">
        <property name="brokerURL" value="tcp://localhost:61616"/>
        <property name="userName" value="admin"/>
        <property name="password" value="admin"/>
        <property name="usePooledConnection" value="false"/>
    </bean>
    <camelContext id="amq-example-context" 
        xmlns="http://camel.apache.org/schema/spring" xmlns:order="http://com.mycompany/examples/order">
        <dataFormats>
            <json id="docsDocs" library="Jackson" unmarshalTypeName="com.mycompany.pojos.MyPojo"/>
        </dataFormats>
        <restConfiguration bindingMode="auto" component="restlet" port="443"/>
        <route id="file-to-jms-route">


            <from id="_to3" uri="timer:order?fixedRate=true&amp;period=5000&amp;delay=2000"/>
            <to id="_to2" uri="restlet:https://my-service.com:443/api/v1.0/user/427?exchangePattern=InOut&restletMethod=GET&auth=1234abcd5678pqrs"/>
            <to id="_to1" uri="file:C:\workspace\jbdevstudio\restfuloutput"/>
            <to id="sendIncomingDocs" uri="activemq:queue:incomingData"/>
        </route>
        <route id="jms-cbr-route" streamCache="true">
            <from id="listenToIncomingData" uri="activemq:queue:incomingData"/>
            <unmarshal id="_unmarshal1">
                <json allowJmsType="true" library="Jackson"/>
            </unmarshal>
            <log id="logEndProcessing" message="Done processing parsing ${body}"/>
            <to id="myQData" uri="activemq:queue:myQData"/>
        </route>
    </camelContext>
</beans>

不确定它是否是一种标准方法,但现在我可以调用服务(任何评论?)。 我们还有多条路径,有没有办法以标准方式配置多个端点:

https://my-service.com:443/api/v1.0/country
https://my-service.com:443/api/v1.0/country/{id}/state/{id2} 
https ://my-service.com:443/api/v1.0/education
https ://my-service.com:443/api/v1.0/roles

同样在此服务调用中,我在查询字符串中发送一个标头(auth = 1234abcd5678pqrs)。 如何使用setHeader设置任何关于setBody的想法(对于多部分文件对象和表单数据)我想从AMQ获取json对象,将其编组为实体类并存储在数据库中。

答案 1 :(得分:0)

您将要创建一个要在Fuse上部署的Camel路由。您可以从多个端点中进行选择,但我建议使用CXF。

这是一个很好的例子(来自官方文档),介绍如何从头开始并运行Web服务端点!

https://access.redhat.com/documentation/en-US/Red_Hat_JBoss_Fuse/6.2.1/html/Getting_Started/Develop.html#Develop-CreateWS

相关问题