Dear all,

I'm going to configure a REST API similar to a (working) HTTP consumer. I tried 
several URLs to call the API operation but get always a HTTP 404.

Do I miss someting (e.g. the reference to the servletName)? Can someone point 
me out which is the API URL for the get operation in my case?

Thanks in advance
Gerald


My Blueprint DSL see below ..

<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0";
                   
xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0";
                   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";>

        <reference id="httpService" 
interface="org.osgi.service.http.HttpService" />

        <bean id="camelServlet" 
class="org.apache.camel.component.servlet.CamelHttpTransportServlet"/>

        <bean class="org.apache.camel.component.osgi.OsgiServletRegisterer"
              init-method="register"
              destroy-method="unregister">
                <property name="servletName" value="APIISP001" />
                <property name="alias" value="/apiisp001" />
                <property name="httpService" ref="httpService" />
                <property name="servlet" ref="camelServlet" />
        </bean>

        <bean id="servlet" 
class="org.apache.camel.component.servlet.ServletComponent" />

        <camelContext id="isp.api.APIISP001" 
xmlns="http://camel.apache.org/schema/blueprint"; streamCache="true" 
useBreadcrumb="true">

                
<!--********************************************************************************-->
                <!-- REST API                                                   
                    -->
                
<!--********************************************************************************-->

                <restConfiguration component="servlet" contextPath="/apiisp001" 
bindingMode="json">
                        <dataFormatProperty key="prettyPrint" value="true" />
                        <apiProperty key="base.path" value="/apiisp001" />
                        <apiProperty key="api.description" value="APIISP001 - 
Test API" />
                        <apiProperty key="api.title" value="APIISP001" />
                        <apiProperty key="api.version" value="1.0.0" />
                </restConfiguration>

                <!-- REST endpoints -->
        <rest path="/apiisp001">
                        <get uri="/1" id="isp.api.APIISP001.get.1">
                                <route>
                                        <!-- send the chunk to direct -->
                                        <to uri="direct-vm:APIISP001.1"/>
                                </route>
                        </get>
                </rest>

        </camelContext>

</blueprint>

One example for a working HTTP consumer find below

<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0";
           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";>

        <reference id="httpService" 
interface="org.osgi.service.http.HttpService" />

        <bean id="camelServlet" 
class="org.apache.camel.component.servlet.CamelHttpTransportServlet"/>

        <bean class="org.apache.camel.component.osgi.OsgiServletRegisterer"
         init-method="register"
         destroy-method="unregister">
                <property name="servletName" value="WEB2SFO" />
                <property name="alias" value="/web2sfo" />
                <property name="httpService" ref="httpService" />
                <property name="servlet" ref="camelServlet" />
        </bean>

        <bean id="servlet" 
class="org.apache.camel.component.servlet.ServletComponent" />

        <camelContext xmlns="http://camel.apache.org/schema/blueprint";>
                <route>
                        <from uri="servlet://get?servletName=WEB2SFO" />
                        <setBody>
                                <constant>execution of /web2sfo/get</constant>
                        </setBody>
                </route>
        </camelContext>

</blueprint>

Here I could later on add a security definition that works well.

Reply via email to