You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Daniel Langevin <da...@shq.gouv.qc.ca> on 2017/11/23 15:27:41 UTC

substring using indexof +1 using simple language

Hi,

i try to retreive domain name from a String containng an email adress with simple language from the body message in single instruction.

I'm using camel 2.17.7

Look my try 

<setHeader headerName="dns.name"><simple>${body.substring(${body.indexOf("@")}++,${body.length})}</simple></setHeader>

but receive this error

org.apache.camel.language.bean.RuntimeBeanExpressionException: Failed to invoke method: substring(15++,30) on null due to: org.apache.camel.component.bean.ParameterBindingException: Error during parameter binding on method: public java.lang.String java.lang.String.substring(int,int) at parameter #0 with type: int with value type: class java.lang.String and value: 15++


if i decomposed it it's work

<setHeader headerName="dnsStart"><simple>${body.indexOf("@")}++</simple></setHeader>
<setHeader headerName="dns.name"><simple>${body.substring(${header.dnsStart},${body.length})}</simple></setHeader>

Is it possible to achieve it in only one instruction ?



Regards




Daniel Langevin










"Le pr�sent courriel peut contenir des renseignements confidentiels et ne s'adresse qu'au destinataire dont le nom appara�t ci-dessus. Si ce courriel vous est parvenu par m�garde, veuillez le supprimer et nous en aviser aussit�t."

Re: Rép. : Re: Restconfiguration using Servlet with Camel in OSGI Karaf

Posted by Daniel Langevin <da...@shq.gouv.qc.ca>.
Hi,

Finally i found the configuration for Spring Configuration (Simply
adding OSGI shema)
Thank you for the track to follow

Here is the way.

A)  file name ABC-REST-0.0.1.XML deployed containg all routes for the
system ABC.

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:camel="http://camel.apache.org/schema/spring"
       xmlns:osgi="http://www.springframework.org/schema/osgi"
       xmlns:cxf="http://camel.apache.org/schema/cxf"
       xsi:schemaLocation="
          http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd 
          http://camel.apache.org/schema/cxf 
http://camel.apache.org/schema/cxf/camel-cxf.xsd 
          http://camel.apache.org/schema/spring 
http://camel.apache.org/schema/spring/camel-spring-2.17.7.xsd 
          http://www.springframework.org/schema/osgi
http://www.springframework.org/schema/osgi/spring-osgi.xsd">

<osgi: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.servlet.osgi.OsgiServletRegisterer"
       init-method="register"
       destroy-method="unregister">
    <property name="alias" value="/rest/ABC"/>
    <property name="httpService" ref="httpService"/>
    <property name="servlet" ref="camelservlet"/>
</bean>


<restConfiguration bindingMode="auto" component="servlet' port="8181"
contextPath="/rest/ABC" />
<rest path="/SendMail">
 <get uri="/{abcIdMail}">
      <to pattern="InOut" uri="direct:abcProcMail"/>
 </get>
</rest>
...


B) file name XYZ-REST-0.0.1.XML deployed containg all routes for the
system XYZ.

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:camel="http://camel.apache.org/schema/spring"
       xmlns:osgi="http://www.springframework.org/schema/osgi"
       xmlns:cxf="http://camel.apache.org/schema/cxf"
       xsi:schemaLocation="
          http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd 
          http://camel.apache.org/schema/cxf 
http://camel.apache.org/schema/cxf/camel-cxf.xsd 
          http://camel.apache.org/schema/spring 
http://camel.apache.org/schema/spring/camel-spring-2.17.7.xsd 
          http://www.springframework.org/schema/osgi
http://www.springframework.org/schema/osgi/spring-osgi.xsd">

<osgi: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.servlet.osgi.OsgiServletRegisterer"
       init-method="register"
       destroy-method="unregister">
    <property name="alias" value="/rest/XYZ"/>
    <property name="httpService" ref="httpService"/>
    <property name="servlet" ref="camelservlet"/>
</bean>


<restConfiguration bindingMode="auto" component="servlet' port="8181"
contextPath="/rest/XYZ" />
<rest path="/GetQuote">
 <get uri="/{xyzIdQuote}">
      <to pattern="InOut" uri="direct:abcProcQuote"/>
 </get>
</rest>
...


Daniel Langevin








>>> Kerry <ka...@avionicengineers.com> 2017-11-28 15:37 >>>
OK if you don't use blueprint then that shouldn't be a problem but I
wouldn't waste time at the moment trying to deploy my example (I need to
update the docs on it to list all the feature dependencies to be
installed in Karaf.. like I say it is a rough example at the moment)

Instead look at the Camel configuration in the two files
rest-camel-bp.xml and rest-time-bp.xml. That should give you an example
of how to set up two separate bundles but having a common path.


On 28/11/17 20:15, Daniel Langevin wrote:
> Hi,
>
> before open the case i tried to include theese lines
into my SPRING
> Bundle. (i don't use BLUEPRINT)
>
>
>
> <beans xmlns="http://www.springframework.org/schema/beans"
>         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>         xmlns:camel="http://camel.apache.org/schema/spring"
>         xmlns:cxf="http://camel.apache.org/schema/cxf"
>         xsi:schemaLocation="
>            http://www.springframework.org/schema/beans 
> http://www.springframework.org/schema/beans/spring-beans-2.5.xsd 
>            http://camel.apache.org/schema/cxf 
> http://camel.apache.org/schema/cxf/camel-cxf.xsd 
>            http://camel.apache.org/schema/spring 
> http://camel.apache.org/schema/spring/camel-spring-2.17.7.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.servlet.osgi.OsgiServletRegisterer"
>         init-method="register"
>         destroy-method="unregister">
>      <property name="alias" value="/rest"/>
>      <property name="httpService" ref="httpService"/>
>      <property name="servlet" ref="camelServlet"/>
> </bean>
>
> but i received error on deployement.
>
> org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid
content
> was found starting with element 'reference'
>
> Do i missed something in my Beans declaration ?
>
>
>
> Daniel
>
>
>
>
>
>
>>>> Kerry <ka...@avionicengineers.com> 2017-11-28 14:34 >>>
> Hi,
>
> I have achieve the exact same thing Daniel (based upon the
> camel-example-servlet-rest-blueprint example available in the GitHub
> repo)
>
> My (rough) example can be found here:
https://github.com/jtkb/cameltest 
>
>
> The two bundles of interest are the 'api' and 'time-api' Maven
modules.
> Take a look at the blueprint XML files under
> resources/OSGI-INF/blueprint.
>
> you'll see the the root context path for both bundles is
> /camel-example-res-blueprint/rest (although for the api bundle it
> extends it further with /user - never tried it without but could be
> worth checking)
>
> Pay close attention to to the restConfiguration and servletName.
>
> BTW, this example as it stands isn't great as it has circular
package
> dependencies - I need to fix that.
>
> Kerry
>
>
> On 28/11/17 16:05, Daniel Langevin wrote:
>> Hi,
>>
>> i try to implement a Rest service In OSGI Karaf 4.0.9  with Camel
> 2.17.7
>> i want to have multiple REST service from more than one bundle
using
> the same port number
>> like this.
>>
>> A)  file name ABC-REST-0.0.1.XML deployed containg all routes for
the
> system ABC.
>> <restConfiguration bindingMode="auto" component="restlet'
port="9101"
> contextPath="/rest/ABC" />
>> <rest path="/SendMail">
>>    <get uri="/{abcIdMail}">
>>         <to pattern="InOut" uri="direct:abcProcMail"/>
>>    </get>
>> </rest>
>> ...
>>
>> call the service with http://serverName:9101/rest/ABC/Sendmail/nnn 
>> recevie a 200 OK
>>
>>
>> B) file name XYZ-REST-0.0.1.XML deployed containg all routes for
the
> system XYZ.
>> <restConfiguration bindingMode="auto" component="restlet'
port="9102"
> contextPath="/rest/XYZ" />
>> <rest path="/GetQuote">
>>    <get uri="/{abcIdQuote}">
>>         <to pattern="InOut" uri="direct:xyzProcQuote"/>
>>    </get>
>> </rest>
>> ...
>> call the service with http://serverName:9102/rest/XYZ/getQuote/nnn 
>> receive a 200 OK
>>
>> I want to be able to bind all my rest services on the same port
using
> http servlet , like this ( no error on deployement )
>> C) file name ABC-REST-0.0.1.XML containg all routes for the system
> ABC.
>> <restConfiguration bindingMode="auto" component="servlet'
port="8181"
> contextPath="/rest/ABC" />
>> <rest path="/SendMail">
>>    <get uri="/{abcIdMail}">
>>         <to pattern="InOut" uri="direct:abcProcMail"/>
>>    </get>
>> </rest>
>> ...
>> call the service with http://serverName:8181/rest/XYZ/getQuote/nnn 
>> receive a 404 url not found
>>
>>
>> aD)fi
le name XYZ-REST-0.0.1.XML containg all routes for the system
> XYZ.
>> <r
> estConfiguration bindingMode="auto" component="servlet' port="8181"
> contextPath="/rest/XYZ" />
>> <rest path="/GetQuote">
>>    <get uri="/{abcIdQuotel}">
>>         <to pattern="InOut" uri="direct:xyzProcQuote"/>
>>    </get>
>> </rest>
>> ...
>> call the service with http://serverName:8181/rest/XYZ/getQuote/nnn 
>> receive a 404 url not found
>>
>>
>>
>> What i missed ?
>> Do i have to refered the http servlet someware in my camel Context
?
>>
>>
>> Thank's
>>
>>
>> Daniel Langevin
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> "Le présent courriel peut contenir des renseignements confidentiels
> et ne s'adresse qu'au destinataire dont le nom apparaît ci-dessus. Si
ce
> courriel vous est parvenu par mégarde, veuillez le supprimer et nous
en
> aviser aussitôt."
>
>
> "Le présent courriel peut contenir des renseignements confidentiels
et ne s'adresse qu'au destinataire dont le nom apparaît ci-dessus. Si ce
courriel vous est parvenu par mégarde, veuillez le supprimer et nous en
aviser aussitôt."



"Le présent courriel peut contenir des renseignements confidentiels et ne s'adresse qu'au destinataire dont le nom apparaît ci-dessus. Si ce courriel vous est parvenu par mégarde, veuillez le supprimer et nous en aviser aussitôt."

substring using indexof +1 using simple language

Posted by Daniel Langevin <da...@shq.gouv.qc.ca>.
Hi,

i try to retreive domain name from a String containng an email adress with simple language from the body message in single instruction.

I'm using camel 2.17.7

Look my try 

<setHeader headerName="dns.name"><simple>${body.substring(${body.indexOf("@")}++,${body.length})}</simple></setHeader>

but receive this error

org.apache.camel.language.bean.RuntimeBeanExpressionException: Failed to invoke method: substring(15++,30) on null due to: org.apache.camel.component.bean.ParameterBindingException: Error during parameter binding on method: public java.lang.String java.lang.String.substring(int,int) at parameter #0 with type: int with value type: class java.lang.String and value: 15++


if i decomposed it it's work

<setHeader headerName="dnsStart"><simple>${body.indexOf("@")}++</simple></setHeader>
<setHeader headerName="dns.name"><simple>${body.substring(${header.dnsStart},${body.length})}</simple></setHeader>

Is it possible to achieve it in only one instruction ?



Regards




Daniel Langevin










"Le pr�sent courriel peut contenir des renseignements confidentiels et ne s'adresse qu'au destinataire dont le nom appara�t ci-dessus. Si ce courriel vous est parvenu par m�garde, veuillez le supprimer et nous en aviser aussit�t."

Rép. : AW: substring using indexof +1 using simple language

Posted by Daniel Langevin <da...@shq.gouv.qc.ca>.
Thank's 

i use this and it works.

<setHeader
headerName="dns.name"><simple>${body.replaceAll(".*@(.*)","$1")}</simple></setHeader>



Daniel

  


>>> 
I recommend to use a regular expression instead.

-----Ursprüngliche Nachricht-----
Von: Daniel Langevin [mailto:daniel.langevin@shq.gouv.qc.ca]
Gesendet: Donnerstag, 23. November 2017 16:28
An: users@camel.apache.org
Betreff: substring using indexof +1 using simple language

Hi,

i try to retreive domain name from a String containng an email adress
with simple language from the body message in single instruction.

I'm using camel 2.17.7

Look my try

<setHeader
headerName="dns.name"><simple>${body.substring(${body.indexOf("@")}++,${body.length})}</simple></setHeader>

but receive this error

org.apache.camel.language.bean.RuntimeBeanExpressionException: Failed
to invoke method: substring(15++,30) on null due to:
org.apache.camel.component.bean.ParameterBindingException: Error during
parameter binding on method: public java.lang.String
java.lang.String.substring(int,int) at parameter #0 with type: int with
value type: class java.lang.String and value: 15++


if i decomposed it it's work

<setHeader
headerName="dnsStart"><simple>${body.indexOf("@")}++</simple></setHeader>
<setHeader
headerName="dns.name"><simple>${body.substring(${header.dnsStart},${body.length})}</simple></setHeader>

Is it possible to achieve it in only one instruction ?



Regards




Daniel Langevin


----------------------------------------------------------------
innogy SE Vorsitzender des Aufsichtsrates: Dr. Werner Brandt
Vorstand: Peter Terium (Vorsitzender), Dr. Hans Buenting,
Dr. Bernhard Guenther, Martin Herrmann, Hildegard Mueller, Uwe Tigges
Sitz der Gesellschaft: Essen, Eingetragen beim Amtsgericht Essen,
Handelsregister-Nr. HRB 27091, USt-IdNr. DE304171711


"Le présent courriel peut contenir des renseignements confidentiels et ne s'adresse qu'au destinataire dont le nom apparaît ci-dessus. Si ce courriel vous est parvenu par mégarde, veuillez le supprimer et nous en aviser aussitôt."

Restconfiguration using Servlet with Camel in OSGI Karaf

Posted by Daniel Langevin <da...@shq.gouv.qc.ca>.
Hi,

i try to implement a Rest service In OSGI Karaf 4.0.9  with Camel 2.17.7
i want to have multiple REST service from more than one bundle using the same port number

like this.

A)  file name ABC-REST-0.0.1.XML deployed containg all routes for the system ABC.

<restConfiguration bindingMode="auto" component="restlet' port="9101" contextPath="/rest/ABC" />
<rest path="/SendMail">
 <get uri="/{abcIdMail}">
      <to pattern="InOut" uri="direct:abcProcMail"/>
 </get>
</rest>
...

call the service with http://serverName:9101/rest/ABC/Sendmail/nnn 
recevie a 200 OK


B) file name XYZ-REST-0.0.1.XML deployed containg all routes for the system XYZ.

<restConfiguration bindingMode="auto" component="restlet' port="9102" contextPath="/rest/XYZ" />
<rest path="/GetQuote">
 <get uri="/{abcIdQuote}">
      <to pattern="InOut" uri="direct:xyzProcQuote"/>
 </get>
</rest>
...
call the service with http://serverName:9102/rest/XYZ/getQuote/nnn 
receive a 200 OK

I want to be able to bind all my rest services on the same port using http servlet , like this ( no error on deployement )

C) file name ABC-REST-0.0.1.XML containg all routes for the system ABC.

<restConfiguration bindingMode="auto" component="servlet' port="8181" contextPath="/rest/ABC" />
<rest path="/SendMail">
 <get uri="/{abcIdMail}">
      <to pattern="InOut" uri="direct:abcProcMail"/>
 </get>
</rest>
...
call the service with http://serverName:8181/rest/XYZ/getQuote/nnn 
receive a 404 url not found


aD)file name XYZ-REST-0.0.1.XML containg all routes for the system XYZ.

<restConfiguration bindingMode="auto" component="servlet' port="8181" contextPath="/rest/XYZ" />
<rest path="/GetQuote">
 <get uri="/{abcIdQuotel}">
      <to pattern="InOut" uri="direct:xyzProcQuote"/>
 </get>
</rest>
...
call the service with http://serverName:8181/rest/XYZ/getQuote/nnn 
receive a 404 url not found



What i missed ?
Do i have to refered the http servlet someware in my camel Context ?


Thank's


Daniel Langevin











"Le pr�sent courriel peut contenir des renseignements confidentiels et ne s'adresse qu'au destinataire dont le nom appara�t ci-dessus. Si ce courriel vous est parvenu par m�garde, veuillez le supprimer et nous en aviser aussit�t."

Attribute 'uri' is not allowed to appear in element 'enrich'

Posted by Daniel Langevin <da...@shq.gouv.qc.ca>.
Hi,

im' using camel 2.17.7 in Karaf 4.09 OSGI, my deployement type is SPRING

i try tu use enrich to get trought a second from for enriching my message i receive an error

 nested exception is org.xml.sax.SAXParseException: cvc-complex-type.3.2.2: Attribute 'uri' is not allowed to appear in element 'enrich'.
 at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:397)[148:org.apache.servicemix.bundles.spring-beans:3.2.18.RELEASE_1]
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:335)[148:org.apache.servicemix.bundles.spring-beans:3.2.18.RELEASE_1]
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)[148:org.apache.servicemix.bundles.spring-beans:3.2.18.RELEASE_1]
        at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)

Here my code: 

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:camel="http://camel.apache.org/schema/spring"
       xmlns:osgi="http://www.springframework.org/schema/osgi"
       xmlns:cxf="http://camel.apache.org/schema/cxf"
       xsi:schemaLocation="
          http://www.springframework.org/schema/beans  http://www.springframework.org/schema/beans/spring-beans-2.5.xsd 
          http://camel.apache.org/schema/cxf  http://camel.apache.org/schema/cxf/camel-cxf.xsd 
          http://camel.apache.org/schema/spring  http://camel.apache.org/schema/spring/camel-spring-2.17.7.xsd 
          http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd">

    <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
        <property name="connectionFactory" >
          <bean class="org.apache.activemq.ActiveMQConnectionFactory">
             <property name="userName" value="${activemq.jms.user}"/>
             <property name="password" value="${activemq.jms.password}"/>
          </bean>
        </property>
    </bean>

<camelContext xmlns="http://camel.apache.org/schema/spring" trace="false">

<route id="route.SYS.ReadJmsMailInputRequest">
   <description> Read mail input request </description>
   <from uri="activemq:queue:jms.SYS.mailReceive?exchangePattern=InOnly"/>
   <convertBodyTo type="java.lang.String" />
    <choice>
       <when><simple>${header.protocoliMail} == "IMAP"</simple>
              <enrich uri="imaps://servername:993?username=xxxxxxxx&amp;password=xxxxxxxx&amp;delete=true&amp;unseen=true&amp;consumer.delay=60000"  />
              <to uri="....................." />
       </when>
    </choice>
</route>

</camelContext>


Why it's not allowed, if i look documentation, it's supposed to.



Regards 

Daniel





"Le pr�sent courriel peut contenir des renseignements confidentiels et ne s'adresse qu'au destinataire dont le nom appara�t ci-dessus. Si ce courriel vous est parvenu par m�garde, veuillez le supprimer et nous en aviser aussit�t."

Re: Attribute 'uri' is not allowed to appear in element 'enrich'

Posted by Claus Ibsen <cl...@gmail.com>.
Its changed in 2.16 onwards, see the docs where there is examples for
older version and newer version

You should do

<enrich>
  <constant>xxx</constant>
</enrich>

See the docs
https://github.com/apache/camel/blob/master/camel-core/src/main/docs/eips/enrich-eip.adoc

Or the old docs
http://camel.apache.org/content-enricher.html



On Fri, Dec 1, 2017 at 6:35 PM, Daniel Langevin
<da...@shq.gouv.qc.ca> wrote:
> Hi,
>
> im' using camel 2.17.7 in Karaf 4.09 OSGI, my deployement type is SPRING
>
> i try tu use enrich to get trought a second from for enriching my message i receive an error
>
>  nested exception is org.xml.sax.SAXParseException: cvc-complex-type.3.2.2: Attribute 'uri' is not allowed to appear in element 'enrich'.
>  at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:397)[148:org.apache.servicemix.bundles.spring-beans:3.2.18.RELEASE_1]
>         at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:335)[148:org.apache.servicemix.bundles.spring-beans:3.2.18.RELEASE_1]
>         at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)[148:org.apache.servicemix.bundles.spring-beans:3.2.18.RELEASE_1]
>         at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
>
> Here my code:
>
> <beans xmlns="http://www.springframework.org/schema/beans"
>        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>        xmlns:camel="http://camel.apache.org/schema/spring"
>        xmlns:osgi="http://www.springframework.org/schema/osgi"
>        xmlns:cxf="http://camel.apache.org/schema/cxf"
>        xsi:schemaLocation="
>           http://www.springframework.org/schema/beans  http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
>           http://camel.apache.org/schema/cxf  http://camel.apache.org/schema/cxf/camel-cxf.xsd
>           http://camel.apache.org/schema/spring  http://camel.apache.org/schema/spring/camel-spring-2.17.7.xsd
>           http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd">
>
>     <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
>         <property name="connectionFactory" >
>           <bean class="org.apache.activemq.ActiveMQConnectionFactory">
>              <property name="userName" value="${activemq.jms.user}"/>
>              <property name="password" value="${activemq.jms.password}"/>
>           </bean>
>         </property>
>     </bean>
>
> <camelContext xmlns="http://camel.apache.org/schema/spring" trace="false">
>
> <route id="route.SYS.ReadJmsMailInputRequest">
>    <description> Read mail input request </description>
>    <from uri="activemq:queue:jms.SYS.mailReceive?exchangePattern=InOnly"/>
>    <convertBodyTo type="java.lang.String" />
>     <choice>
>        <when><simple>${header.protocoliMail} == "IMAP"</simple>
>               <enrich uri="imaps://servername:993?username=xxxxxxxx&amp;password=xxxxxxxx&amp;delete=true&amp;unseen=true&amp;consumer.delay=60000"  />
>               <to uri="....................." />
>        </when>
>     </choice>
> </route>
>
> </camelContext>
>
>
> Why it's not allowed, if i look documentation, it's supposed to.
>
>
>
> Regards
>
> Daniel
>
>
>
>
>
> "Le présent courriel peut contenir des renseignements confidentiels et ne s'adresse qu'au destinataire dont le nom apparaît ci-dessus. Si ce courriel vous est parvenu par mégarde, veuillez le supprimer et nous en aviser aussitôt."



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Re: Restconfiguration using Servlet with Camel in OSGI Karaf

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Yeah I think it has been talked before about osgi and rest here or on
stackoverflow. You can configure camel-servlet for osgi with some
"magic" osgi http service stuff.

On Tue, Nov 28, 2017 at 5:05 PM, Daniel Langevin
<da...@shq.gouv.qc.ca> wrote:
> Hi,
>
> i try to implement a Rest service In OSGI Karaf 4.0.9  with Camel 2.17.7
> i want to have multiple REST service from more than one bundle using the same port number
>
> like this.
>
> A)  file name ABC-REST-0.0.1.XML deployed containg all routes for the system ABC.
>
> <restConfiguration bindingMode="auto" component="restlet' port="9101" contextPath="/rest/ABC" />
> <rest path="/SendMail">
>  <get uri="/{abcIdMail}">
>       <to pattern="InOut" uri="direct:abcProcMail"/>
>  </get>
> </rest>
> ...
>
> call the service with http://serverName:9101/rest/ABC/Sendmail/nnn
> recevie a 200 OK
>
>
> B) file name XYZ-REST-0.0.1.XML deployed containg all routes for the system XYZ.
>
> <restConfiguration bindingMode="auto" component="restlet' port="9102" contextPath="/rest/XYZ" />
> <rest path="/GetQuote">
>  <get uri="/{abcIdQuote}">
>       <to pattern="InOut" uri="direct:xyzProcQuote"/>
>  </get>
> </rest>
> ...
> call the service with http://serverName:9102/rest/XYZ/getQuote/nnn
> receive a 200 OK
>
> I want to be able to bind all my rest services on the same port using http servlet , like this ( no error on deployement )
>
> C) file name ABC-REST-0.0.1.XML containg all routes for the system ABC.
>
> <restConfiguration bindingMode="auto" component="servlet' port="8181" contextPath="/rest/ABC" />
> <rest path="/SendMail">
>  <get uri="/{abcIdMail}">
>       <to pattern="InOut" uri="direct:abcProcMail"/>
>  </get>
> </rest>
> ...
> call the service with http://serverName:8181/rest/XYZ/getQuote/nnn
> receive a 404 url not found
>
>
> aD)file name XYZ-REST-0.0.1.XML containg all routes for the system XYZ.
>
> <restConfiguration bindingMode="auto" component="servlet' port="8181" contextPath="/rest/XYZ" />
> <rest path="/GetQuote">
>  <get uri="/{abcIdQuotel}">
>       <to pattern="InOut" uri="direct:xyzProcQuote"/>
>  </get>
> </rest>
> ...
> call the service with http://serverName:8181/rest/XYZ/getQuote/nnn
> receive a 404 url not found
>
>
>
> What i missed ?
> Do i have to refered the http servlet someware in my camel Context ?
>
>
> Thank's
>
>
> Daniel Langevin
>
>
>
>
>
>
>
>
>
>
>
> "Le présent courriel peut contenir des renseignements confidentiels et ne s'adresse qu'au destinataire dont le nom apparaît ci-dessus. Si ce courriel vous est parvenu par mégarde, veuillez le supprimer et nous en aviser aussitôt."



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Re: Restconfiguration using Servlet with Camel in OSGI Karaf

Posted by Kerry <ka...@avionicengineers.com>.
Hi,

I have achieve the exact same thing Daniel (based upon the camel-example-servlet-rest-blueprint example available in the GitHub repo)

My (rough) example can be found here: https://github.com/jtkb/cameltest

The two bundles of interest are the 'api' and 'time-api' Maven modules. Take a look at the blueprint XML files under resources/OSGI-INF/blueprint.

you'll see the the root context path for both bundles is /camel-example-res-blueprint/rest (although for the api bundle it extends it further with /user - never tried it without but could be worth checking)

Pay close attention to to the restConfiguration and servletName.

BTW, this example as it stands isn't great as it has circular package dependencies - I need to fix that.

Kerry


On 28/11/17 16:05, Daniel Langevin wrote:
> Hi,
>
> i try to implement a Rest service In OSGI Karaf 4.0.9  with Camel 2.17.7
> i want to have multiple REST service from more than one bundle using the same port number
>
> like this.
>
> A)  file name ABC-REST-0.0.1.XML deployed containg all routes for the system ABC.
>
> <restConfiguration bindingMode="auto" component="restlet' port="9101" contextPath="/rest/ABC" />
> <rest path="/SendMail">
>   <get uri="/{abcIdMail}">
>        <to pattern="InOut" uri="direct:abcProcMail"/>
>   </get>
> </rest>
> ...
>
> call the service with http://serverName:9101/rest/ABC/Sendmail/nnn
> recevie a 200 OK
>
>
> B) file name XYZ-REST-0.0.1.XML deployed containg all routes for the system XYZ.
>
> <restConfiguration bindingMode="auto" component="restlet' port="9102" contextPath="/rest/XYZ" />
> <rest path="/GetQuote">
>   <get uri="/{abcIdQuote}">
>        <to pattern="InOut" uri="direct:xyzProcQuote"/>
>   </get>
> </rest>
> ...
> call the service with http://serverName:9102/rest/XYZ/getQuote/nnn
> receive a 200 OK
>
> I want to be able to bind all my rest services on the same port using http servlet , like this ( no error on deployement )
>
> C) file name ABC-REST-0.0.1.XML containg all routes for the system ABC.
>
> <restConfiguration bindingMode="auto" component="servlet' port="8181" contextPath="/rest/ABC" />
> <rest path="/SendMail">
>   <get uri="/{abcIdMail}">
>        <to pattern="InOut" uri="direct:abcProcMail"/>
>   </get>
> </rest>
> ...
> call the service with http://serverName:8181/rest/XYZ/getQuote/nnn
> receive a 404 url not found
>
>
> aD)file name XYZ-REST-0.0.1.XML containg all routes for the system XYZ.
>
> <restConfiguration bindingMode="auto" component="servlet' port="8181" contextPath="/rest/XYZ" />
> <rest path="/GetQuote">
>   <get uri="/{abcIdQuotel}">
>        <to pattern="InOut" uri="direct:xyzProcQuote"/>
>   </get>
> </rest>
> ...
> call the service with http://serverName:8181/rest/XYZ/getQuote/nnn
> receive a 404 url not found
>
>
>
> What i missed ?
> Do i have to refered the http servlet someware in my camel Context ?
>
>
> Thank's
>
>
> Daniel Langevin
>
>
>
>
>
>
>
>
>
>
>
> "Le présent courriel peut contenir des renseignements confidentiels et ne s'adresse qu'au destinataire dont le nom apparaît ci-dessus. Si ce courriel vous est parvenu par mégarde, veuillez le supprimer et nous en aviser aussitôt."
>


Re: Restconfiguration using Servlet with Camel in OSGI Karaf

Posted by Claus Ibsen <cl...@gmail.com>.
Sorry for being a bit short on details, but I dont have the osgi
example at hand here.

On Tue, Nov 28, 2017 at 6:34 PM, Claus Ibsen <cl...@gmail.com> wrote:
> Hi
>
> Yeah I think it has been talked before about osgi and rest here or on
> stackoverflow. You can configure camel-servlet for osgi with some
> "magic" osgi http service stuff.
>
> On Tue, Nov 28, 2017 at 5:05 PM, Daniel Langevin
> <da...@shq.gouv.qc.ca> wrote:
>> Hi,
>>
>> i try to implement a Rest service In OSGI Karaf 4.0.9  with Camel 2.17.7
>> i want to have multiple REST service from more than one bundle using the same port number
>>
>> like this.
>>
>> A)  file name ABC-REST-0.0.1.XML deployed containg all routes for the system ABC.
>>
>> <restConfiguration bindingMode="auto" component="restlet' port="9101" contextPath="/rest/ABC" />
>> <rest path="/SendMail">
>>  <get uri="/{abcIdMail}">
>>       <to pattern="InOut" uri="direct:abcProcMail"/>
>>  </get>
>> </rest>
>> ...
>>
>> call the service with http://serverName:9101/rest/ABC/Sendmail/nnn
>> recevie a 200 OK
>>
>>
>> B) file name XYZ-REST-0.0.1.XML deployed containg all routes for the system XYZ.
>>
>> <restConfiguration bindingMode="auto" component="restlet' port="9102" contextPath="/rest/XYZ" />
>> <rest path="/GetQuote">
>>  <get uri="/{abcIdQuote}">
>>       <to pattern="InOut" uri="direct:xyzProcQuote"/>
>>  </get>
>> </rest>
>> ...
>> call the service with http://serverName:9102/rest/XYZ/getQuote/nnn
>> receive a 200 OK
>>
>> I want to be able to bind all my rest services on the same port using http servlet , like this ( no error on deployement )
>>
>> C) file name ABC-REST-0.0.1.XML containg all routes for the system ABC.
>>
>> <restConfiguration bindingMode="auto" component="servlet' port="8181" contextPath="/rest/ABC" />
>> <rest path="/SendMail">
>>  <get uri="/{abcIdMail}">
>>       <to pattern="InOut" uri="direct:abcProcMail"/>
>>  </get>
>> </rest>
>> ...
>> call the service with http://serverName:8181/rest/XYZ/getQuote/nnn
>> receive a 404 url not found
>>
>>
>> aD)file name XYZ-REST-0.0.1.XML containg all routes for the system XYZ.
>>
>> <restConfiguration bindingMode="auto" component="servlet' port="8181" contextPath="/rest/XYZ" />
>> <rest path="/GetQuote">
>>  <get uri="/{abcIdQuotel}">
>>       <to pattern="InOut" uri="direct:xyzProcQuote"/>
>>  </get>
>> </rest>
>> ...
>> call the service with http://serverName:8181/rest/XYZ/getQuote/nnn
>> receive a 404 url not found
>>
>>
>>
>> What i missed ?
>> Do i have to refered the http servlet someware in my camel Context ?
>>
>>
>> Thank's
>>
>>
>> Daniel Langevin
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> "Le présent courriel peut contenir des renseignements confidentiels et ne s'adresse qu'au destinataire dont le nom apparaît ci-dessus. Si ce courriel vous est parvenu par mégarde, veuillez le supprimer et nous en aviser aussitôt."
>
>
>
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Rép. : Re: Attribute 'uri' is not allowed to appear in element 'enrich'

Posted by Daniel Langevin <da...@shq.gouv.qc.ca>.
Hi Claus,

thanks , i will point on new documentation in the future .
OK now it Works


Have a nive weekend !






>>> Claus Ibsen <cl...@gmail.com> 2017-12-01 13:50 >>>
Its changed in 2.16 onwards, see the docs where there is examples for
older version and newer version

You should do

<enrich>
  <constant>xxx</constant>
</enrich>

See the docs
https://github.com/apache/camel/blob/master/camel-core/src/main/docs/eips/enrich-eip.adoc


Or the old docs
http://camel.apache.org/content-enricher.html 



On Fri, Dec 1, 2017 at 6:35 PM, Daniel Langevin
<da...@shq.gouv.qc.ca> wrote:
> Hi,
>
> im' using camel 2.17.7 in Karaf 4.09 OSGI, my deployement type is
SPRING
>
> i try tu use enrich to get trought a second from for enriching my
message i receive an error
>
>  nested exception is org.xml.sax.SAXParseException:
cvc-complex-type.3.2.2: Attribute 'uri' is not allowed to appear in
element 'enrich'.
>  at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:397)[148:org.apache.servicemix.bundles.spring-beans:3.2.18.RELEASE_1]
>         at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:335)[148:org.apache.servicemix.bundles.spring-beans:3.2.18.RELEASE_1]
>         at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)[148:org.apache.servicemix.bundles.spring-beans:3.2.18.RELEASE_1]
>         at
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
>
> Here my code:
>
> <beans xmlns="http://www.springframework.org/schema/beans"
>        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>        xmlns:camel="http://camel.apache.org/schema/spring"
>        xmlns:osgi="http://www.springframework.org/schema/osgi"
>        xmlns:cxf="http://camel.apache.org/schema/cxf"
>        xsi:schemaLocation="
>           http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd 
>           http://camel.apache.org/schema/cxf 
http://camel.apache.org/schema/cxf/camel-cxf.xsd 
>           http://camel.apache.org/schema/spring 
http://camel.apache.org/schema/spring/camel-spring-2.17.7.xsd 
>           http://www.springframework.org/schema/osgi
http://www.springframework.org/schema/osgi/spring-osgi.xsd">
>
>     <bean id="activemq"
class="org.apache.activemq.camel.component.ActiveMQComponent">
>         <property name="connectionFactory" >
>           <bean
class="org.apache.activemq.ActiveMQConnectionFactory">
>              <property name="userName"
value="${activemq.jms.user}"/>
>              <property name="password"
value="${activemq.jms.password}"/>
>           </bean>
>         </property>
>     </bean>
>
> <camelContext xmlns="http://camel.apache.org/schema/spring"
trace="false">
>
> <route id="route.SYS.ReadJmsMailInputRequest">
>    <description> Read mail input request </description>
>    <from
uri="activemq:queue:jms.SYS.mailReceive?exchangePattern=InOnly"/>
>    <convertBodyTo type="java.lang.String" />
>     <choice>
>        <when><simple>${header.protocoliMail} == "IMAP"</simple>
>               <enrich
uri="imaps://servername:993?username=xxxxxxxx&amp;password=xxxxxxxx&amp;delete=true&amp;unseen=true&amp;consumer.delay=60000"
 />
>               <to uri="....................." />
>        </when>
>     </choice>
> </route>
>
> </camelContext>
>
>
> Why it's not allowed, if i look documentation, it's supposed to.
>
>
>
> Regards
>
> Daniel
>
>
>
>
>
> "Le présent courriel peut contenir des renseignements confidentiels
et ne s'adresse qu'au destinataire dont le nom apparaît ci-dessus. Si ce
courriel vous est parvenu par mégarde, veuillez le supprimer et nous en
aviser aussitôt."



-- 
Claus Ibsen
---------------
--
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2


"Le présent courriel peut contenir des renseignements confidentiels et ne s'adresse qu'au destinataire dont le nom apparaît ci-dessus. Si ce courriel vous est parvenu par mégarde, veuillez le supprimer et nous en aviser aussitôt."

Rép. : Re: Restconfiguration using Servlet with Camel in OSGI Karaf

Posted by Daniel Langevin <da...@shq.gouv.qc.ca>.
Hi,

before open the case i tried to include theese lines into my SPRING
Bundle. (i don't use BLUEPRINT)



<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:camel="http://camel.apache.org/schema/spring"
       xmlns:cxf="http://camel.apache.org/schema/cxf"
       xsi:schemaLocation="
          http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd 
          http://camel.apache.org/schema/cxf 
http://camel.apache.org/schema/cxf/camel-cxf.xsd 
          http://camel.apache.org/schema/spring   
http://camel.apache.org/schema/spring/camel-spring-2.17.7.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.servlet.osgi.OsgiServletRegisterer"
       init-method="register"
       destroy-method="unregister">
    <property name="alias" value="/rest"/>
    <property name="httpService" ref="httpService"/>
    <property name="servlet" ref="camelServlet"/>
</bean>

but i received error on deployement.

org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content
was found starting with element 'reference'

Do i missed something in my Beans declaration ?



Daniel






>>> Kerry <ka...@avionicengineers.com> 2017-11-28 14:34 >>>
Hi,

I have achieve the exact same thing Daniel (based upon the
camel-example-servlet-rest-blueprint example available in the GitHub
repo)

My (rough) example can be found here: https://github.com/jtkb/cameltest


The two bundles of interest are the 'api' and 'time-api' Maven modules.
Take a look at the blueprint XML files under
resources/OSGI-INF/blueprint.

you'll see the the root context path for both bundles is
/camel-example-res-blueprint/rest (although for the api bundle it
extends it further with /user - never tried it without but could be
worth checking)

Pay close attention to to the restConfiguration and servletName.

BTW, this example as it stands isn't great as it has circular package
dependencies - I need to fix that.

Kerry


On 28/11/17 16:05, Daniel Langevin wrote:
> Hi,
>
> i try to implement a Rest service In OSGI Karaf 4.0.9  with Camel
2.17.7
> i want to have multiple REST service from more than one bundle using
the same port number
>
> like this.
>
> A)  file name ABC-REST-0.0.1.XML deployed containg all routes for the
system ABC.
>
> <restConfiguration bindingMode="auto" component="restlet' port="9101"
contextPath="/rest/ABC" />
> <rest path="/SendMail">
>   <get uri="/{abcIdMail}">
>        <to pattern="InOut" uri="direct:abcProcMail"/>
>   </get>
> </rest>
> ...
>
> call the service with http://serverName:9101/rest/ABC/Sendmail/nnn 
> recevie a 200 OK
>
>
> B) file name XYZ-REST-0.0.1.XML deployed containg all routes for the
system XYZ.
>
> <restConfiguration bindingMode="auto" component="restlet' port="9102"
contextPath="/rest/XYZ" />
> <rest path="/GetQuote">
>   <get uri="/{abcIdQuote}">
>        <to pattern="InOut" uri="direct:xyzProcQuote"/>
>   </get>
> </rest>
> ...
> call the service with http://serverName:9102/rest/XYZ/getQuote/nnn 
> receive a 200 OK
>
> I want to be able to bind all my rest services on the same port using
http servlet , like this ( no error on deployement )
>
> C) file name ABC-REST-0.0.1.XML containg all routes for the system
ABC.
>
> <restConfiguration bindingMode="auto" component="servlet' port="8181"
contextPath="/rest/ABC" />
> <rest path="/SendMail">
>   <get uri="/{abcIdMail}">
>        <to pattern="InOut" uri="direct:abcProcMail"/>
>   </get>
> </rest>
> ...
> call the service with http://serverName:8181/rest/XYZ/getQuote/nnn 
> receive a 404 url not found
>
>
> aD)file name XYZ-REST-0.0.1.XML containg all routes for the system
XYZ.
>
> <r
estConfiguration bindingMode="auto" component="servlet' port="8181"
contextPath="/rest/XYZ" />
> <rest path="/GetQuote">
>   <get uri="/{abcIdQuotel}">
>        <to pattern="InOut" uri="direct:xyzProcQuote"/>
>   </get>
> </rest>
> ...
> call the service with http://serverName:8181/rest/XYZ/getQuote/nnn 
> receive a 404 url not found
>
>
>
> What i missed ?
> Do i have to refered the http servlet someware in my camel Context ?
>
>
> Thank's
>
>
> Daniel Langevin
>
>
>
>
>
>
>
>
>
>
>
> "Le présent courriel peut contenir des renseignements confidentiels
et ne s'adresse qu'au destinataire dont le nom apparaît ci-dessus. Si ce
courriel vous est parvenu par mégarde, veuillez le supprimer et nous en
aviser aussitôt."
>



"Le présent courriel peut contenir des renseignements confidentiels et ne s'adresse qu'au destinataire dont le nom apparaît ci-dessus. Si ce courriel vous est parvenu par mégarde, veuillez le supprimer et nous en aviser aussitôt."

Re: Restconfiguration using Servlet with Camel in OSGI Karaf

Posted by Mark <el...@gmail.com>.
If I'm understanding your deployment correctly, you just need to make sure
the proper camel bundles/features are deployed.  What OSGi container are
you using and what do your logs say?


On Tue, Nov 28, 2017 at 12:35 PM, Claus Ibsen <cl...@gmail.com> wrote:

> Sorry for being a bit short on details, but I dont have the osgi
> example at hand here.
>
> On Tue, Nov 28, 2017 at 6:34 PM, Claus Ibsen <cl...@gmail.com>
> wrote:
> > Hi
> >
> > Yeah I think it has been talked before about osgi and rest here or on
> > stackoverflow. You can configure camel-servlet for osgi with some
> > "magic" osgi http service stuff.
> >
> > On Tue, Nov 28, 2017 at 5:05 PM, Daniel Langevin
> > <da...@shq.gouv.qc.ca> wrote:
> >> Hi,
> >>
> >> i try to implement a Rest service In OSGI Karaf 4.0.9  with Camel 2.17.7
> >> i want to have multiple REST service from more than one bundle using
> the same port number
> >>
> >> like this.
> >>
> >> A)  file name ABC-REST-0.0.1.XML deployed containg all routes for the
> system ABC.
> >>
> >> <restConfiguration bindingMode="auto" component="restlet' port="9101"
> contextPath="/rest/ABC" />
> >> <rest path="/SendMail">
> >>  <get uri="/{abcIdMail}">
> >>       <to pattern="InOut" uri="direct:abcProcMail"/>
> >>  </get>
> >> </rest>
> >> ...
> >>
> >> call the service with http://serverName:9101/rest/ABC/Sendmail/nnn
> >> recevie a 200 OK
> >>
> >>
> >> B) file name XYZ-REST-0.0.1.XML deployed containg all routes for the
> system XYZ.
> >>
> >> <restConfiguration bindingMode="auto" component="restlet' port="9102"
> contextPath="/rest/XYZ" />
> >> <rest path="/GetQuote">
> >>  <get uri="/{abcIdQuote}">
> >>       <to pattern="InOut" uri="direct:xyzProcQuote"/>
> >>  </get>
> >> </rest>
> >> ...
> >> call the service with http://serverName:9102/rest/XYZ/getQuote/nnn
> >> receive a 200 OK
> >>
> >> I want to be able to bind all my rest services on the same port using
> http servlet , like this ( no error on deployement )
> >>
> >> C) file name ABC-REST-0.0.1.XML containg all routes for the system ABC.
> >>
> >> <restConfiguration bindingMode="auto" component="servlet' port="8181"
> contextPath="/rest/ABC" />
> >> <rest path="/SendMail">
> >>  <get uri="/{abcIdMail}">
> >>       <to pattern="InOut" uri="direct:abcProcMail"/>
> >>  </get>
> >> </rest>
> >> ...
> >> call the service with http://serverName:8181/rest/XYZ/getQuote/nnn
> >> receive a 404 url not found
> >>
> >>
> >> aD)file name XYZ-REST-0.0.1.XML containg all routes for the system XYZ.
> >>
> >> <restConfiguration bindingMode="auto" component="servlet' port="8181"
> contextPath="/rest/XYZ" />
> >> <rest path="/GetQuote">
> >>  <get uri="/{abcIdQuotel}">
> >>       <to pattern="InOut" uri="direct:xyzProcQuote"/>
> >>  </get>
> >> </rest>
> >> ...
> >> call the service with http://serverName:8181/rest/XYZ/getQuote/nnn
> >> receive a 404 url not found
> >>
> >>
> >>
> >> What i missed ?
> >> Do i have to refered the http servlet someware in my camel Context ?
> >>
> >>
> >> Thank's
> >>
> >>
> >> Daniel Langevin
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >> "Le présent courriel peut contenir des renseignements confidentiels et
> ne s'adresse qu'au destinataire dont le nom apparaît ci-dessus. Si ce
> courriel vous est parvenu par mégarde, veuillez le supprimer et nous en
> aviser aussitôt."
> >
> >
> >
> > --
> > Claus Ibsen
> > -----------------
> > http://davsclaus.com @davsclaus
> > Camel in Action 2: https://www.manning.com/ibsen2
>
>
>
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
>

Re: Rép. : Re: Restconfiguration using Servlet with Camel in OSGI Karaf

Posted by Kerry <ka...@avionicengineers.com>.
OK if you don't use blueprint then that shouldn't be a problem but I wouldn't waste time at the moment trying to deploy my example (I need to update the docs on it to list all the feature dependencies to be installed in Karaf.. like I say it is a rough example at the moment)

Instead look at the Camel configuration in the two files rest-camel-bp.xml and rest-time-bp.xml. That should give you an example of how to set up two separate bundles but having a common path.


On 28/11/17 20:15, Daniel Langevin wrote:
> Hi,
>
> before open the case i tried to include theese lines into my SPRING
> Bundle. (i don't use BLUEPRINT)
>
>
>
> <beans xmlns="http://www.springframework.org/schema/beans"
>         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>         xmlns:camel="http://camel.apache.org/schema/spring"
>         xmlns:cxf="http://camel.apache.org/schema/cxf"
>         xsi:schemaLocation="
>            http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
>            http://camel.apache.org/schema/cxf
> http://camel.apache.org/schema/cxf/camel-cxf.xsd
>            http://camel.apache.org/schema/spring
> http://camel.apache.org/schema/spring/camel-spring-2.17.7.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.servlet.osgi.OsgiServletRegisterer"
>         init-method="register"
>         destroy-method="unregister">
>      <property name="alias" value="/rest"/>
>      <property name="httpService" ref="httpService"/>
>      <property name="servlet" ref="camelServlet"/>
> </bean>
>
> but i received error on deployement.
>
> org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content
> was found starting with element 'reference'
>
> Do i missed something in my Beans declaration ?
>
>
>
> Daniel
>
>
>
>
>
>
>>>> Kerry <ka...@avionicengineers.com> 2017-11-28 14:34 >>>
> Hi,
>
> I have achieve the exact same thing Daniel (based upon the
> camel-example-servlet-rest-blueprint example available in the GitHub
> repo)
>
> My (rough) example can be found here: https://github.com/jtkb/cameltest
>
>
> The two bundles of interest are the 'api' and 'time-api' Maven modules.
> Take a look at the blueprint XML files under
> resources/OSGI-INF/blueprint.
>
> you'll see the the root context path for both bundles is
> /camel-example-res-blueprint/rest (although for the api bundle it
> extends it further with /user - never tried it without but could be
> worth checking)
>
> Pay close attention to to the restConfiguration and servletName.
>
> BTW, this example as it stands isn't great as it has circular package
> dependencies - I need to fix that.
>
> Kerry
>
>
> On 28/11/17 16:05, Daniel Langevin wrote:
>> Hi,
>>
>> i try to implement a Rest service In OSGI Karaf 4.0.9  with Camel
> 2.17.7
>> i want to have multiple REST service from more than one bundle using
> the same port number
>> like this.
>>
>> A)  file name ABC-REST-0.0.1.XML deployed containg all routes for the
> system ABC.
>> <restConfiguration bindingMode="auto" component="restlet' port="9101"
> contextPath="/rest/ABC" />
>> <rest path="/SendMail">
>>    <get uri="/{abcIdMail}">
>>         <to pattern="InOut" uri="direct:abcProcMail"/>
>>    </get>
>> </rest>
>> ...
>>
>> call the service with http://serverName:9101/rest/ABC/Sendmail/nnn
>> recevie a 200 OK
>>
>>
>> B) file name XYZ-REST-0.0.1.XML deployed containg all routes for the
> system XYZ.
>> <restConfiguration bindingMode="auto" component="restlet' port="9102"
> contextPath="/rest/XYZ" />
>> <rest path="/GetQuote">
>>    <get uri="/{abcIdQuote}">
>>         <to pattern="InOut" uri="direct:xyzProcQuote"/>
>>    </get>
>> </rest>
>> ...
>> call the service with http://serverName:9102/rest/XYZ/getQuote/nnn
>> receive a 200 OK
>>
>> I want to be able to bind all my rest services on the same port using
> http servlet , like this ( no error on deployement )
>> C) file name ABC-REST-0.0.1.XML containg all routes for the system
> ABC.
>> <restConfiguration bindingMode="auto" component="servlet' port="8181"
> contextPath="/rest/ABC" />
>> <rest path="/SendMail">
>>    <get uri="/{abcIdMail}">
>>         <to pattern="InOut" uri="direct:abcProcMail"/>
>>    </get>
>> </rest>
>> ...
>> call the service with http://serverName:8181/rest/XYZ/getQuote/nnn
>> receive a 404 url not found
>>
>>
>> aD)file name XYZ-REST-0.0.1.XML containg all routes for the system
> XYZ.
>> <r
> estConfiguration bindingMode="auto" component="servlet' port="8181"
> contextPath="/rest/XYZ" />
>> <rest path="/GetQuote">
>>    <get uri="/{abcIdQuotel}">
>>         <to pattern="InOut" uri="direct:xyzProcQuote"/>
>>    </get>
>> </rest>
>> ...
>> call the service with http://serverName:8181/rest/XYZ/getQuote/nnn
>> receive a 404 url not found
>>
>>
>>
>> What i missed ?
>> Do i have to refered the http servlet someware in my camel Context ?
>>
>>
>> Thank's
>>
>>
>> Daniel Langevin
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> "Le présent courriel peut contenir des renseignements confidentiels
> et ne s'adresse qu'au destinataire dont le nom apparaît ci-dessus. Si ce
> courriel vous est parvenu par mégarde, veuillez le supprimer et nous en
> aviser aussitôt."
>
>
> "Le présent courriel peut contenir des renseignements confidentiels et ne s'adresse qu'au destinataire dont le nom apparaît ci-dessus. Si ce courriel vous est parvenu par mégarde, veuillez le supprimer et nous en aviser aussitôt."


Rép. : Re: Restconfiguration using Servlet with Camel in OSGI Karaf

Posted by Daniel Langevin <da...@shq.gouv.qc.ca>.
Hi,

i use KARAF as OSGI

i deploy camel-servlet


an no error in the log 
 FeaturesServiceImpl                 | 8 -
org.apache.karaf.features.core - 4.0.9 | Adding features:
camel-servlet/[2.17.7,2.17.7]
 FeaturesServiceImpl                 | 8 -
org.apache.karaf.features.core - 4.0.9 | Changes to perform:
 FeaturesServiceImpl                 | 8 -
org.apache.karaf.features.core - 4.0.9 |   Region: root
 FeaturesServiceImpl                 | 8 -
org.apache.karaf.features.core - 4.0.9 |     Bundles to install:
 FeaturesServiceImpl                 | 8 -
org.apache.karaf.features.core - 4.0.9 |      
mvn:org.apache.camel/camel-servlet/2.17.7
 FeaturesServiceImpl                 | 8 -
org.apache.karaf.features.core - 4.0.9 | Installing bundles:
 FeaturesServiceImpl                 | 8 -
org.apache.karaf.features.core - 4.0.9 |  
mvn:org.apache.camel/camel-servlet/2.17.7
 FeaturesServiceImpl                 | 8 -
org.apache.karaf.features.core - 4.0.9 | Starting bundles:
 FeaturesServiceImpl                 | 8 -
org.apache.karaf.features.core - 4.0.9 |  
org.apache.camel.camel-servlet/2.17.7
 FeaturesServiceImpl                 | 8 -
org.apache.karaf.features.core - 4.0.9 | Done.

Daniel





>>> Mark <el...@gmail.com> 2017-11-28 12:46 >>>
If I'm understanding your deployment correctly, you just need to make
sure
the proper camel bundles/features are deployed.  What OSGi container
are
you using and what do your logs say?


On Tue, Nov 28, 2017 at 12:35 PM, Claus Ibsen <cl...@gmail.com>
wrote:

> Sorry for being a bit short on details, but I dont have the osgi
> example at hand here.
>
> On Tue, Nov 28, 2017 at 6:34 PM, Claus Ibsen <cl...@gmail.com>
> wrote:
> > Hi
> >
> > Yeah I think it has been talked before about osgi and rest here or
on
> > stackoverflow. You can configure camel-servlet for osgi with some
> > "magic" osgi http service stuff.
> >
> > On Tue, Nov 28, 2017 at 5:05 PM, Daniel Langevin
> > <da...@shq.gouv.qc.ca> wrote:
> >> Hi,
> >>
> >> i try to implement a Rest service In OSGI Karaf 4.0.9  with Camel
2.17.7
> >> i want to have multiple REST service from more than one bundle
using
> the same port number
> >>
> >> like this.
> >>
> >> A)  file name ABC-REST-0.0.1.XML deployed containg all routes for
the
> system ABC.
> >>
> >> <restConfiguration bindingMode="auto" component="restlet'
port="9101"
> contextPath="/rest/ABC" />
> >> <rest path="/SendMail">
> >>  <get uri="/{abcIdMail}">
> >>       <to pattern="InOut" uri="direct:abcProcMail"/>
> >>  </get>
> >> </rest>
> >> ...
> >>
> >> call the service with http://serverName:9101/rest/ABC/Sendmail/nnn

> >> recevie a 200 OK
> >>
> >>
> >> B) file name XYZ-REST-0.0.1.XML deployed containg all routes for
the
> system XYZ.
> >>
> >> <restConfiguration bindingMode="auto" component="restlet'
port="9102"
> contextPath="/rest/XYZ" />
> >> <rest path="/GetQuote">
> >>  <get uri="/{abcIdQuote}">
> >>       <to pattern="InOut" uri="direct:xyzProcQuote"/>
> >>  </get>
> >> </rest>
> >> ...
> >> call the service with http://serverName:9102/rest/XYZ/getQuote/nnn

> >> receive a 200 OK
> >>
> >> I want to be able to bind all my rest services on the same port
using
> http servlet , like this ( no error on deployement )
> >>
> >> C) file name ABC-REST-0.0.1.XML containg all routes for the system
ABC.
> >>
> >> <restConfiguration bindingMode="auto" component="servlet'
port="8181"
> contextPath="/rest/ABC" />
> >> <rest path="/SendMail">
> >>  <get uri="/{abcIdMail}">
> >>       <to pattern="InOut" uri="direct:abcProcMail"/>
> >>  </get>
> >> </rest>
> >> ...
> >> call the service with http://serverName:8181/rest/XYZ/getQuote/nnn

> >> receive a 404 url not found
> >>
> >>
> >> aD)file name XYZ-REST-0.0.1.XML containg all routes for the system
XYZ.
> >>
> >> <restConfiguration bindingMode="auto" component="servlet'
port="8181"
> contextPath="/rest/XYZ"
/>
> >> <rest path="/GetQuote">
> >>  <get uri="/{abcIdQuotel}">
> >>       <to pattern="InOut" uri="direct:xyzProcQuote"/>
> >>  </get>
> >> </rest>
> >> ...
> >> call the service with http://serverName:8181/rest/XYZ/getQuote/nnn

> >> receive a 404 url not found
> >>
> >>
> >>
> >> What i missed ?
> >> Do i have to refered the http servlet someware in my camel Context
?
> >>
> >>
> >> Thank's
> >>
> >>
> >> Daniel Langevin
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >> "Le présent courriel peut contenir des renseignements
confidentiels et
> ne s'adresse qu'au destinataire dont le nom apparaît ci-dessus. Si
ce
> courriel vous est parvenu par mégarde, veuillez le supprimer et nous
en
> aviser aussitôt."
> >
> >
> >
> > --
> > Claus Ibsen
> > -----------------
> > http://davsclaus.com @davsclaus
> > Camel in Action 2: https://www.manning.com/ibsen2 
>
>
>
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2 
>


"Le présent courriel peut contenir des renseignements confidentiels et ne s'adresse qu'au destinataire dont le nom apparaît ci-dessus. Si ce courriel vous est parvenu par mégarde, veuillez le supprimer et nous en aviser aussitôt."