0 Replies Latest reply on Aug 1, 2018 3:16 AM by guha_gourab

    Rest service returning 404 Not Found developed using Rest DSL in Fuse 7

    guha_gourab

      Hi,

      I am using Fuse Karaf 7.0.0 and have created one blueprint OSGI bundle for implementing a Rest and SOAP both. For SOAP I am using cxf and it is running fine. For Rest where I have chosen to use Rest DSL is compiled and bundled successfully but not running. While calling the Rest service from client it is throwing 404 Not Found and no error log is generated in Karaf. I am clueless. One important point is, I am keeping both Rest and SOAP configuration both in same blueprint XML.

       

      Here is my blueprint XML

       

      <?xml version="1.0" encoding="UTF-8"?>

      <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"

      xmlns:cxf="http://camel.apache.org/schema/blueprint/cxf"

      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

      xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0           https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd          http://camel.apache.org/schema/blueprint/cxf           http://camel.apache.org/schema/blueprint/cxf/camel-cxf.xsd          http://camel.apache.org/schema/blueprint           http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">

       

      <reference id="httpService"

      interface="org.osgi.service.http.HttpService" />

       

      <bean id="camel-servlet"

      class="org.apache.camel.component.servlet.CamelHttpTransportServlet" />

       

      <bean

      class="org.apache.camel.component.servlet.osgi.OsgiServletRegisterer"

      init-method="register" destroy-method="unregister">

      <property name="alias" value="/cs_interface" />

      <property name="httpService" ref="httpService" />

      <property name="servlet" ref="camel-servlet" />

      <property name="servletName" value="camel-servlet" />

      </bean>

       

      <bean id="restRouteBuilder"

      class="com.xxx.middleware.service.cs_interface2.RestRouteBuilder" />

      <cxf:cxfEndpoint address="/report/" id="reportEndpoint"

      serviceClass="com.xxx.middleware.service.cs_interface2.incident.IncidentService">

      <!-- <cxf:properties> <entry key="dataFormat" value="PAYLOAD"/> </cxf:properties> -->

      </cxf:cxfEndpoint>

       

      <bean

      class="com.xxx.middleware.service.cs_interface2.incident.ReportIncidentProcessor"

      id="reportIncidentProcessor" />

       

      <bean

      class="com.xxx.middleware.service.cs_interface2.incident.StatusIncidentProcessor"

      id="statusIncidentProcessor" />

       

      <camelContext

      id="camelContext-4791e7e5-857d-4c5e-a77f-f1205fc0294a"

      xmlns="http://camel.apache.org/schema/blueprint">

       

      <routeBuilder ref="restRouteBuilder" />

      <route id="cxf">

      <!-- route starts from the cxf webservice in POJO mode -->

      <from id="_from1" uri="cxf:bean:reportEndpoint" />

      <log id="_log3" message="body:${body}" />

      <recipientList id="_recipientList1">

      <simple>direct:${header.operationName}</simple>

      </recipientList>

       

      </route>

      <route id="report">

      <from id="_from2" uri="direct:reportIncident" />

      <log id="_log1" message="reportIncident Call" />

      <log id="_log4" message="body:${body}" />

      <process id="_process1" ref="reportIncidentProcessor" />

      <to id="_to1" uri="log:output" />

      </route>

       

       

      <route id="status">

      <from id="_from3" uri="direct:statusIncident" />

      <log id="_log2" message="statusIncident Call" />

      <process id="_process2" ref="statusIncidentProcessor" />

      <to id="_to2" uri="log:output" />

      </route>

      </camelContext>

      </blueprint>

       

      And the route builder is:

       

      restConfiguration().component("servlet").bindingMode(RestBindingMode.json).port("8181").setContextPath("/cs_interface");;

       

      rest("/resttest").consumes("application/json").produces("application/json").post("/hit").type(InputReportIncident.class)

      .outType(OutputReportIncident.class).description("Incident service")

      .to("direct:proc?exchangePattern=InOut");

       

      from("direct:proc").process(new ReportIncidentProcessor());

       

      URL I am using to call -> http://localhost:8181/report/cs_interface/resttest/hit

      with this JSON

      {

        "incidentId" : "324232",

        "incidentDate" : "31July2017",

        "givenName" : "Gourab",

        "familyName" : "Guha",

        "summary" : "Nothing",

        "details" : "No details",

        "email" : "xxx@yyy.com",

        "phone" : "123456654"

      }