HI,  i found my problem.

sorry for the disturb.


The answer is in:
the servername.org already format the response in JSON format, so don't
have to transform the BODY receive.

it's Wrong, rest servlet try to generat automatically Json, thats the
probleme.

i only add 
<convertBodyTo type="java.lang.String"/>
after <to uri="http://dummyhost>

and now it Works.


Thank's 



Daniel











>>> "Daniel Langevin" <daniel.lange...@shq.gouv.qc.ca> 2018-02-22 14:20
>>>
Hi,

i try to implement a Rest service In OSGI Karaf 4.0.9  with Camel
2.17.7
this service redirect with camel‑http to another URL.

like 
http://serverA.org:8181/rest/XXX/geocode/30%20rue%20larue,%20quebec/adress/geom

redirect to
http://www.servername.org/search/geocode?q=300%20rue%20larue,%20quebec&type=adress&geometries=geom


the servername.org already format the response in JSON format, so don't
have to transform the BODY receive.

When i try with a standard Browser like, Firefox, Safari, Google
Chrome, etc. it works very well .

When i try with application Browser like utl_http from Oracle or wget
or Curl i receive and HTTP error 500 from Jetty ????
Nothing in the karaf LOG

The request send to my remote server, it respond 200 OK and return de
DATA as well 
but after all data was receive 
jetty return an error to my application 

witch TCPDUMP i saw:

HTTP/1.1 500 Server Error
Date: Thu, 22 Feb 2018 18:54:23 GMT
Server: Jetty(9.2.19.v20160908)
Content‑Type: text/plain; charset=ISO‑8859‑1
Connection: close
com.fasterxml.jackson.databind.JsonMappingException: No serializer
found for class
org.apache.camel.converter.stream.CachedOutputStream$WrappedInputStream
and no properties discovered to create BeanSerializer (to avoid
exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) )


I DON'T find what happend ??????  Any idea ????????

Thank's  in Advance



Daniel



Here my code:

<?xml version="1.0" encoding="UTF‑8"?>
<beans xmlns="http://www.springframework.org/schema/beans";
       xmlns:xsi="http://www.w3.org/2001/XMLSchema‑instance";
      
xmlns:wsse="http://docs.oasis‑open.org/wss/2004/01/oasis‑200401‑wss‑wssecurity‑secext‑1.0.xsd";
       xmlns:cxf="http://camel.apache.org/schema/cxf";
       xmlns:camel="http://camel.apache.org/schema/spring";
       xmlns:osgi="http://www.springframework.org/schema/osgi";
       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="TERCamelServlet"
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/XXX"/>
      <property name="httpService" ref="httpService"/>
      <property name="servlet" ref="XXXCamelServlet"/>
      <property name="servletName" value="XXXCamelServlet"/>
</bean>

<camelContext id="Contexte‑XXX‑XXX"
xmlns="http://camel.apache.org/schema/spring"; trace="false" >

<restConfiguration bindingMode="auto" component="servlet" port="8181"
contextPath="/rest/XXX" >
  <endpointProperty key="servletName" value="XXXCamelServlet" />
  <dataFormatProperty key="prettyPrint" value="true"/>
</restConfiguration>

<rest path="/geocode">
<get uri="/{geoRequete}">
   <to pattern="InOut" uri="direct:xxxGeocode" />
 </get>
 <get uri="/{geoRequete}/{geoType}">
   <to pattern="InOut" uri="
direct:xxxGeocode" />
 </get>
 <get uri="/{geoRequete}/{geoType}/{Geogeometries}">
   <to pattern="InOut" uri="direct:xxxGeocode" />
 </get>

<route id="route.XXX.geocode" startupOrder="004" streamCache="true">
   <from uri="direct:xxxGeocode" />
   ...   
   ...
   some validation
   ...
   ...
   <setHeader
headerName="Exchange.HTTP_URI"><simple>http://www.servername.org/search</setHeader>
   <setHeader
headerName="Exchange.HTTP_PATH"><simple>geocode</simple></setHeader>
   <setHeader
headerName="Exchange.HTTP_QUERY"><simple>q=${header.geoRequete}${header.geoType}${header.geoGeometries}${headergeoFiltre}</simple></setHeader>
   <to uri="http://dummyhost>
   <onException>
          
<exception>org.apache.camel.http.common.HttpOperationFailedException</exception>
           <handled> <constant>true</constant> </handled>
           <log message="*** Error receive from remote server ***"/>
   </onException>   
</route>

</camelContext>
</beans>









"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."

Reply via email to