Hi Gerald,

the only way i know to do that is to refer this way.

 uri="direct-vm:xxxxxxxxxxxxxx?block=true&timeout=300000"




hope this help!



Daniel
>>> 
De : Gerald Kallas <catsh...@mailbox.org>
À :<users@camel.apache.org>, Daniel Langevin <daniel.lange...@shq.gouv.qc.ca>
Date : 2020-08-19 00:15
Objet : Re: Rép. : Camel REST DSL with servlet - API URL?
The idea is to define a servlet once and to re-use it with it's context in 
multiple routes in different Blueprint files.

Best
Gerald

> Gerald Kallas <catsh...@mailbox.org> hat am 18.08.2020 22:35 geschrieben:
> 
>  
> Thanks a lot, Daniel. It works.
> 
> Is it possible to refer to a servlet that has been defined in another 
> Blueprint file?
> 
> Best
> Gerald
> 
> > Daniel Langevin <daniel.lange...@shq.gouv.qc.ca> hat am 18.08.2020 14:29 
> > geschrieben:
> > 
> >  
> > Try this it's work for me.
> > 
> > 
> > 
> > <restConfiguration component="servlet" contextPath="/apiisp001" 
> >                                 bindingMode="json" scheme="https" 
> > port="8443"
> >                                 apiContextPath="/api-doc" 
> > apiContextListing="false" enableCORS="true">
> > <!-- 
> >       Add apiContextpath to give the possibility to list all service on 
> > apiisp001 Context with Camel Swagger
> >       with that request: https://localhost:8443/apiisp001/api-doc 

> > -->
> > 
> > <!-- Add this line to create a independant servlet prevent Conflict with a 
> > previous declare in other CamelContext -->
> >              <endpointProperty key="servletName" 
> > value="apiisp001CamelServlet" />
> > 
> >     <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" />
> >              <apiProperty key="api.contact.name" value="Gerald Kallas"/>
> >              <apiProperty key="api.contact.email" 
> > value="catsh...@mailbox.org"/>
> >              <apiProperty key="api.termsOfService" value="(C) xxxxxxxxxxxx 
> > 2020"/>
> > 
> > </restConfiguration>
> > 
> > <!-- 
> >        Add this little URI to test connectivity of you rest API 
> >        with that request: https://localhost:8443/apiisp001/echo/ping 

> > -->
> > 
> > <rest path="/echo" consumes="text/html" produces="text/html">
> >  <description>apiisp001 - Echo rest service</description>
> >  <get uri="ping">
> >      <description>APIISP001 - Connectivity test </description>
> >      <route id="rte.APIISP001.rest.echo">
> >              <transform>
> >                 <constant>/APIISP001/echo  PONG.</constant>
> >              </transform>
> >      </route>
> >  </get>
> > </rest>
> > 
> > Daniel Langevin
> > Direction de l’assistance et des technologies
> > Direction des ressources informationnelles
> >  
> > Société d’habitation du Québec
> > Édifice Marie-Guyart
> > 1054, rue Louis-Alexandre-Taschereau
> > Aile Jacques-Parizeau, 1er étage
> > Québec (Québec) G1R 5E7
> > Téléphone : 418 643-4035, poste 1191
> > Sans frais : 1 800 463-4315
> > 
> > 
> > 
> > 
> > 
> > 
> > >>> 
> > De :        Gerald Kallas <catsh...@mailbox.org>
> > À : <users@camel.apache.org>, Daniel Langevin 
> > <daniel.lange...@shq.gouv.qc.ca>
> > Date :      2020-08-18 03:33
> > Objet :     Re: Rép. : Camel REST DSL with servlet - API URL?
> > 
> > Thanks for the hint. But it doesn't work either. I modified my Blueprint as 
> > following
> > 
> > <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";
( 'https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd";') >

> > 
> >     <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" scheme="https" port="8443">
> >                     <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="/base">
> >                     <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>
> > 
> > The (untertow) web server runs with HTTPS on port 8443, other servlets are 
> > working. I tried
> > 
> > https://localhost:8443/apiisp001/base/1 

> > 
> > where I'd expect the response but did get a HTTP 404 error.
> > 
> > Any hints are appreciated.
> > 
> > See also the log for deployment
> > 
> > 2020-08-18T07:31:28,421 | INFO  | 
> > fileinstall-/opt/apache-karaf-4.2.9/deploy | BlueprintContainerImpl         
> >   | 105 - org.apache.aries.blueprint.core - 1.10.2 | Blueprint bundle 
> > isp.api.APIISP001.xml/0.0.0 has been started
> > 2020-08-18T07:31:28,432 | INFO  | Blueprint Event Dispatcher: 1 | 
> > BlueprintCamelContext              | 169 - 
> > org.apache.camel.karaf.camel-blueprint - 3.4.2 | Attempting to start 
> > CamelContext: isp.api.APIISP001
> > 2020-08-18T07:31:28,437 | INFO  | Blueprint Event Dispatcher: 1 | 
> > JmxManagementStrategy              | 144 - 
> > org.apache.camel.camel-management - 3.4.2 | JMX is enabled
> > 2020-08-18T07:31:28,484 | INFO  | Blueprint Event Dispatcher: 1 | 
> > AbstractCamelContext                | 115 - org.apache.camel.camel-base - 
> > 3.4.2 | Apache Camel 3.4.2 (isp.api.APIISP001) is starting
> > 2020-08-18T07:31:28,484 | INFO  | Blueprint Event Dispatcher: 1 | 
> > AbstractCamelContext                | 115 - org.apache.camel.camel-base - 
> > 3.4.2 | StreamCaching is enabled on CamelContext: isp.api.APIISP001
> > 2020-08-18T07:31:28,546 | INFO  | Blueprint Event Dispatcher: 1 | 
> > AbstractCamelContext                | 115 - org.apache.camel.camel-base - 
> > 3.4.2 | Using HealthCheck: camel-health
> > 2020-08-18T07:31:28,592 | INFO  | Blueprint Event Dispatcher: 1 | 
> > DefaultStreamCachingStrategy     | 115 - org.apache.camel.camel-base - 
> > 3.4.2 | StreamCaching in use with spool directory: 
> > /opt/apache-karaf/data/tmp/camel/camel-tmp-ID-43c92ad4274c-1597499175862-121-1
> >  and rules: [Spool > 128K body size]
> > 2020-08-18T07:31:28,593 | INFO  | Blueprint Event Dispatcher: 1 | 
> > JacksonDataFormat                          | 137 - 
> > org.apache.camel.camel-jackson - 3.4.2 | The option 
> > autoDiscoverObjectMapper is set to false, Camel won't search in the registry
> > 2020-08-18T07:31:28,594 | INFO  | Blueprint Event Dispatcher: 1 | 
> > JacksonDataFormat                          | 137 - 
> > org.apache.camel.camel-jackson - 3.4.2 | The option 
> > autoDiscoverObjectMapper is set to false, Camel won't search in the registry
> > 2020-08-18T07:31:28,625 | INFO  | Blueprint Event Dispatcher: 1 | 
> > InternalRouteStartupManager      | 115 - org.apache.camel.camel-base - 
> > 3.4.2 | Route: isp.api.APIISP001.get.1 started and consuming from: 
> > servlet:/apiisp001/1
> > 2020-08-18T07:31:28,626 | INFO  | Blueprint Event Dispatcher: 1 | 
> > AbstractCamelContext                | 115 - org.apache.camel.camel-base - 
> > 3.4.2 | Total 1 routes, of which 1 are started
> > 2020-08-18T07:31:28,626 | INFO  | Blueprint Event Dispatcher: 1 | 
> > AbstractCamelContext                | 115 - org.apache.camel.camel-base - 
> > 3.4.2 | Apache Camel 3.4.2 (isp.api.APIISP001) started in 0.142 seconds
> > 2020-08-18T07:31:28,643 | INFO  | 
> > fileinstall-/opt/apache-karaf-4.2.9/deploy | fileinstall                    
> >                  | 10 - org.apache.felix.fileinstall - 3.6.6 | Started 
> > bundle: blueprint:file:/opt/apache-karaf-4.2.9/deploy/isp.api.APIISP001.xml
> > 
> > Best
> > Gerald
> > 
> > > Daniel Langevin <daniel.lange...@shq.gouv.qc.ca> hat am 17.08.2020 17:44 
> > > geschrieben:
> > > 
> > >  
> > > Hi,
> > > 
> > > you have to specify the default http port number : 8181 for CamelServlet
> > > 
> > > like this:
> > > 
> > > http://servername.org:8181/apiisp001/1 

> > > 
> > > 
> > > 
> > > 
> > > Daniel Langevin
> > > Direction de l’assistance et des technologies
> > > Direction des ressources informationnelles
> > >  
> > > Société d’habitation du Québec
> > > Édifice Marie-Guyart
> > > 1054, rue Louis-Alexandre-Taschereau
> > > Aile Jacques-Parizeau, 1er étage
> > > Québec (Québec) G1R 5E7
> > > Téléphone : 418 643-4035, poste 1191
> > > Sans frais : 1 800 463-4315
> > > 
> > > 
> > > 
> > > 
> > > 
> > > >>> 
> > > De :      Gerald Kallas <catsh...@mailbox.org>
> > > À :       "users@camel.apache.org" <users@camel.apache.org>
> > > Date :    2020-08-17 11:22
> > > Objet :   Camel REST DSL with servlet - API URL?
> > > 
> > > 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";
( '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";
( '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