-1

I am using JBoss FUSE for integration. I am new to it. I want to consume/call third party restful webservices. Please can anyone tell me what will be the best approach to create endpoint (like cxf, restlet, etc.).

Also if there is any working end-to-end example, that will be of great help.

Thanks in advance.

Java User
  • 21
  • 2

2 Answers2

1

Finally, I can call rest service below is my snippet:

<?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>

Not sure whether its a standard approach but now i am able to call service (Any comments?). Also we have multiple paths like, is there any way to configure multiple end points in standard way:

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

Also in this service call i am sending one header (auth=1234abcd5678pqrs) in query string. How to set using setHeader also any idea about setBody (for multipart file objects and form-data ) I want to get the json object from AMQ, marshal it to entity class and store in database.

Java User
  • 21
  • 2
0

You are going to want to create a Camel route to deploy on Fuse. You can select from a number of endpoints, but I suggest CXF.

Here is a great example (from the official documentation) of how to start from scratch and get a web service endpoint running!

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

R. Stroop
  • 31
  • 2
  • Hi Stroop - I just want to consume third party RESTful web-service. The example here seems that it creates the SOAP web-service. – Java User Jan 12 '17 at 22:06