You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by antb59 <an...@gmail.com> on 2014/10/09 15:44:02 UTC

Http bridgeEndpoint to proxy a distant server

Hello,

I'm trying to build some kind of Rest proxy with Camel : 
 1 - A restlet endpoint will receive POST request with JSON body
 2 - The body will be transformed into a XML request using freemarker
 3 - The xml request will be sent to a distant HTTP server
 4 - The HTTP server will send a XML response in a synchronous way
 5 - The response will be transformed in JSON using freemarker
 6 - The JSON response will be forwarded to the client

Steps 1 to 4 works well, without a line of code !
But I'm facing some troubles with steps 4 : the HTTP distant server answer
is an InputStream, and I'm not able to transform it.

Here is my context configuration :

	<bean id="RestletComponent" class="org.restlet.Component" />
 
	<bean id="RestletComponentService"
class="org.apache.camel.component.restlet.RestletComponent">
		<constructor-arg index="0">
			<ref bean="RestletComponent" />
		</constructor-arg>
	</bean>
	
	<camelContext xmlns="http://camel.apache.org/schema/spring" trace="true">
		
		<route id="RS_RestletDemo">
			<from uri="restlet:/identification?restletMethod=POST" />
			<transform>
				<simple>${bodyAs(String)}</simple>
			</transform>
			<to uri="freemarker:identification.xml"/>
			<setHeader headerName="CamelHttpMethod">
				<constant>POST</constant>
			</setHeader>
			<to uri="http://distantserver:8012/test/identification.xml" />
			<convertBodyTo type="java.lang.String"/>
		</route> 
	</camelContext>


This configuration works (steps 5-6 are not present).
However if I add lines below convertBodyTo, the request to the restlet
server hangs and never answer :

<route id="RS_RestletDemo">
	<from uri="restlet:/identification?restletMethod=POST" />
	<transform>
		<simple>${bodyAs(String)}</simple>
	</transform>
	<to uri="freemarker:identification.xml"/>
	<setHeader headerName="CamelHttpMethod">
		<constant>POST</constant>
	</setHeader>
	<to uri="http://distantserver:8012/test/identification.xml" />
	<convertBodyTo type="java.lang.String"/>
	<marshal ref="xmljsonWithOptions"/>
</route> 

When I check the logs, the JSON conversion seems to work fine.
I checked samples about http proxy in camel there :
http://camel.apache.org/how-to-use-camel-as-a-http-proxy-between-a-client-and-server.html
http://blog.sedona.fr/2013/03/introduction-aux-eips-suite-mise-en-pratique-avec-apache-camel/

But I can't found a sample where the message out of the distant server is
used and converted before returning to client.

Is it possible ?

Here are the logs when request is hanging and never returned :

2014-10-09 15:16:09,319 [bio-8080-exec-3] DEBUG MethodBasedRouter             
- MethodRouter (/identification) received request method: POST
2014-10-09 15:16:09,319 [bio-8080-exec-3] DEBUG RestletConsumer               
- Consumer restlet handle request method: POST
2014-10-09 15:16:09,324 [bio-8080-exec-3] DEBUG DefaultRestletBinding         
- Populate exchange from Restlet request header: org.restlet.http.version
value: 1.1
2014-10-09 15:16:09,324 [bio-8080-exec-3] DEBUG DefaultRestletBinding         
- Populate exchange from Restlet request header: org.restlet.http.headers
value: [[host: localhost:8080], [connection: keep-alive], [content-length:
77], [cache-control: no-cache], [origin:
chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop], [content-type:
application/json], [user-agent: Mozilla/5.0 (Windows NT 6.1; WOW64)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36],
[postman-token: eb6c491c-b940-05a2-4409-47fbf6139644], [accept: */*],
[accept-encoding: gzip,deflate], [accept-language:
fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4], [cookie:
JSESSIONID=099AEDE2231A37E97E62E92986FE7481.9DFE950A9AAAD24F9A]]
2014-10-09 15:16:09,324 [bio-8080-exec-3] DEBUG DefaultRestletBinding         
- Populate exchange from Restlet request header: org.restlet.startTime
value: 1412860569318
2014-10-09 15:16:09,347 [bio-8080-exec-3] INFO  Tracer                        
- ID-L82680-58528-1412860563831-0-2 >>> (RS_RestletDemo)
from(/identification?restletMethods=POST) --> transform[Simple:
${bodyAs(String)}] <<< Pattern:InOut, Headers:{CamelRestletRequest=POST
http://localhost:8080/wfs-rest/api/identification HTTP/1.1,
CamelRestletResponse=HTTP/1.1 - OK (200) - The request has succeeded,
org.restlet.http.version=1.1, org.restlet.startTime=1412860569318,
org.restlet.http.headers=[[host: localhost:8080], [connection: keep-alive],
[content-length: 77], [cache-control: no-cache], [origin:
chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop], [content-type:
application/json], [user-agent: Mozilla/5.0 (Windows NT 6.1; WOW64)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36],
[postman-token: eb6c491c-b940-05a2-4409-47fbf6139644], [accept: */*],
[accept-encoding: gzip,deflate], [accept-language:
fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4], [cookie:
JSESSIONID=099AEDE2231A37E97E62E92986FE7481.9DFE950A9AAAD24F9A]],
CamelHttpMethod=POST,
CamelHttpUri=http://localhost:8080/wfs-rest/api/identification,
Content-Type=application/json,
breadcrumbId=ID-L82680-58528-1412860563831-0-1},
BodyType:org.apache.camel.converter.stream.InputStreamCache, Body:[Body is
instance of org.apache.camel.StreamCache]
2014-10-09 15:16:09,351 [bio-8080-exec-3] DEBUG DefaultListableBeanFactory    
- Creating instance of bean
'org.apache.camel.language.simple.SimpleLanguage'
2014-10-09 15:16:09,351 [bio-8080-exec-3] DEBUG DefaultListableBeanFactory    
- Finished creating instance of bean
'org.apache.camel.language.simple.SimpleLanguage'
2014-10-09 15:16:09,366 [bio-8080-exec-3] INFO  Tracer                        
- ID-L82680-58528-1412860563831-0-2 >>> (RS_RestletDemo) transform[Simple:
${bodyAs(String)}] --> freemarker://identification.xml <<< Pattern:InOut,
Headers:{org.restlet.http.headers=[[host: localhost:8080], [connection:
keep-alive], [content-length: 77], [cache-control: no-cache], [origin:
chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop], [content-type:
application/json], [user-agent: Mozilla/5.0 (Windows NT 6.1; WOW64)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36],
[postman-token: eb6c491c-b940-05a2-4409-47fbf6139644], [accept: */*],
[accept-encoding: gzip,deflate], [accept-language:
fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4], [cookie:
JSESSIONID=099AEDE2231A37E97E62E92986FE7481.9DFE950A9AAAD24F9A]],
CamelHttpUri=http://localhost:8080/wfs-rest/api/identification,
CamelRestletRequest=POST http://localhost:8080/wfs-rest/api/identification
HTTP/1.1, org.restlet.http.version=1.1, org.restlet.startTime=1412860569318,
CamelHttpMethod=POST, Content-Type=application/json,
breadcrumbId=ID-L82680-58528-1412860563831-0-1,
CamelRestletResponse=HTTP/1.1 - OK (200) - The request has succeeded},
BodyType:String, Body:{
	"login" : "toto",
 	"password" : "a743edbeb4610c5f793508df0c3f0711"
}

2014-10-09 15:16:09,367 [bio-8080-exec-3] DEBUG SendProcessor                 
- >>>> Endpoint[freemarker://identification.xml] Exchange[Message: {
	"login" : "toto",
 	"password" : "toto"
}
]
2014-10-09 15:16:09,368 [bio-8080-exec-3] DEBUG FreemarkerEndpoint            
- Freemarker is evaluating identification.xml using context:
{response=Message: {
	"login" : "toto",
 	"password" : "toto"
}
, headers={org.restlet.http.headers=[[host: localhost:8080], [connection:
keep-alive], [content-length: 77], [cache-control: no-cache], [origin:
chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop], [content-type:
application/json], [user-agent: Mozilla/5.0 (Windows NT 6.1; WOW64)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36],
[postman-token: eb6c491c-b940-05a2-4409-47fbf6139644], [accept: */*],
[accept-encoding: gzip,deflate], [accept-language:
fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4], [cookie:
JSESSIONID=099AEDE2231A37E97E62E92986FE7481.9DFE950A9AAAD24F9A]],
CamelHttpUri=http://localhost:8080/wfs-rest/api/identification,
CamelRestletRequest=POST http://localhost:8080/wfs-rest/api/identification
HTTP/1.1, org.restlet.http.version=1.1, org.restlet.startTime=1412860569318,
CamelHttpMethod=POST, Content-Type=application/json,
breadcrumbId=ID-L82680-58528-1412860563831-0-1,
CamelRestletResponse=HTTP/1.1 - OK (200) - The request has succeeded},
body={
	"login" : "toto",
 	"password" : "toto"
}
, camelContext=SpringCamelContext(camel-1) with spring id
org.springframework.web.context.WebApplicationContext:/wfs-rest,
request=Message: {
	"login" : "toto",
 	"password" : "toto"
}
, in=Message: {
	"login" : "toto",
 	"password" : "toto"
}
, exchange=Exchange[Message: {
	"login" : "toto",
 	"password" : "toto"
}
], out=Message: {
	"login" : "toto",
 	"password" : "toto"
}
}
2014-10-09 15:16:09,376 [bio-8080-exec-3] DEBUG cache                         
- Could not find template in cache, creating new one;
id=["identification.xml"["fr_FR",Cp1252,parsed] ]
2014-10-09 15:16:09,380 [bio-8080-exec-3] DEBUG cache                         
- Compiling FreeMarker template "identification.xml"["fr_FR",Cp1252,parsed] 
from "file:/D:/wfs-rest-camel/WEB-INF/classes/identification.xml"
2014-10-09 15:16:09,528 [bio-8080-exec-3] INFO  Tracer                        
- ID-L82680-58528-1412860563831-0-2 >>> (RS_RestletDemo)
freemarker://identification.xml --> setHeader[CamelHttpMethod] <<<
Pattern:InOut, Headers:{org.restlet.http.headers=[[host: localhost:8080],
[connection: keep-alive], [content-length: 77], [cache-control: no-cache],
[origin: chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop],
[content-type: application/json], [user-agent: Mozilla/5.0 (Windows NT 6.1;
WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124
Safari/537.36], [postman-token: eb6c491c-b940-05a2-4409-47fbf6139644],
[accept: */*], [accept-encoding: gzip,deflate], [accept-language:
fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4], [cookie:
JSESSIONID=099AEDE2231A37E97E62E92986FE7481.9DFE950A9AAAD24F9A]],
CamelHttpUri=http://localhost:8080/wfs-rest/api/identification,
CamelRestletRequest=POST http://localhost:8080/wfs-rest/api/identification
HTTP/1.1, org.restlet.http.version=1.1, org.restlet.startTime=1412860569318,
CamelHttpMethod=POST, Content-Type=application/json,
breadcrumbId=ID-L82680-58528-1412860563831-0-1,
CamelRestletResponse=HTTP/1.1 - OK (200) - The request has succeeded},
BodyType:String, Body:<?xml version="1.0" encoding="iso-8859-1"?>
<identificationRequest 
	v="1.0"
	mgrUserID="toto" 
	clUserID="toto" 
	clMediaID="WEB"  
	pwd="toto" 
	mgrMediaID="OMS" 
	mgrUserIP="127.0.0.1">
</identificationRequest>


2014-10-09 15:16:09,529 [bio-8080-exec-3] INFO  Tracer                        
- ID-L82680-58528-1412860563831-0-2 >>> (RS_RestletDemo)
setHeader[CamelHttpMethod] -->
http://distantserver:8012/test/identification.xml?bridgeEndpoint=true <<<
Pattern:InOut, Headers:{org.restlet.http.headers=[[host: localhost:8080],
[connection: keep-alive], [content-length: 77], [cache-control: no-cache],
[origin: chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop],
[content-type: application/json], [user-agent: Mozilla/5.0 (Windows NT 6.1;
WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124
Safari/537.36], [postman-token: eb6c491c-b940-05a2-4409-47fbf6139644],
[accept: */*], [accept-encoding: gzip,deflate], [accept-language:
fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4], [cookie:
JSESSIONID=099AEDE2231A37E97E62E92986FE7481.9DFE950A9AAAD24F9A]],
CamelRestletResponse=HTTP/1.1 - OK (200) - The request has succeeded,
CamelHttpMethod=POST,
CamelHttpUri=http://localhost:8080/wfs-rest/api/identification,
CamelRestletRequest=POST http://localhost:8080/wfs-rest/api/identification
HTTP/1.1, breadcrumbId=ID-L82680-58528-1412860563831-0-1,
Content-Type=application/json, org.restlet.startTime=1412860569318,
org.restlet.http.version=1.1}, BodyType:String, Body:<?xml version="1.0"
encoding="iso-8859-1"?>
<identificationRequest 
	v="1.0"
	mgrUserID="toto" 
	clUserID="toto" 
	clMediaID="WEB"  
	pwd="toto" 
	mgrMediaID="OMS" 
	mgrUserIP="127.0.0.1">
</identificationRequest>


2014-10-09 15:16:09,529 [bio-8080-exec-3] DEBUG SendProcessor                 
- >>>>
Endpoint[http://distantserver:8012/test/identification.xml?bridgeEndpoint=true]
Exchange[Message: <?xml version="1.0" encoding="iso-8859-1"?>
<identificationRequest 
	v="1.0"
	mgrUserID="toto" 
	clUserID="toto" 
	clMediaID="WEB"  
	pwd="toto" 
	mgrMediaID="OMS" 
	mgrUserIP="127.0.0.1">
</identificationRequest>

]
2014-10-09 15:16:09,543 [bio-8080-exec-3] DEBUG DefaultTypeConverter          
- Promoting fallback type converter as a known type converter to convert
from: org.apache.camel.component.http.HttpMethods to: java.lang.String for
the fallback converter:
org.apache.camel.impl.converter.EnumTypeConverter@809a88
2014-10-09 15:16:09,571 [bio-8080-exec-3] DEBUG HttpProducer                  
- Executing http POST method:
http://distantserver:8012/test/identification.xml?bridgeEndpoint=true
2014-10-09 15:16:09,578 [bio-8080-exec-3] DEBUG
iThreadedHttpConnectionManager - HttpConnectionManager.getConnection: 
config = HostConfiguration[host=http://localhost:8012], timeout = 0
2014-10-09 15:16:09,579 [bio-8080-exec-3] DEBUG
iThreadedHttpConnectionManager - Allocating new connection,
hostConfig=HostConfiguration[host=http://localhost:8012]
2014-10-09 15:16:09,583 [bio-8080-exec-3] DEBUG HttpConnection                
- Open connection to localhost:8012
2014-10-09 15:16:09,586 [bio-8080-exec-3] DEBUG header                        
- >> "POST /useraccount/identification.xml HTTP/1.1[\r][\n]"
2014-10-09 15:16:09,586 [bio-8080-exec-3] DEBUG HttpMethodBase                
- Adding Host request header
2014-10-09 15:16:09,594 [bio-8080-exec-3] DEBUG header                        
- >> "org.restlet.http.headers: [[host: localhost:8080], [connection:
keep-alive], [content-length: 77], [cache-control: no-cache], [origin:
chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop], [content-type:
application/json], [user-agent: Mozilla/5.0 (Windows NT 6.1; WOW64)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36],
[postman-token: eb6c491c-b940-05a2-4409-47fbf6139644], [accept: */*],
[accept-encoding: gzip,deflate], [accept-language:
fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4], [cookie:
JSESSIONID=099AEDE2231A37E97E62E92986FE7481.9DFE950A9AAAD24F9A]][\r][\n]"
2014-10-09 15:16:09,594 [bio-8080-exec-3] DEBUG header                        
- >> "breadcrumbId: ID-L82680-58528-1412860563831-0-1[\r][\n]"
2014-10-09 15:16:09,594 [bio-8080-exec-3] DEBUG header                        
- >> "org.restlet.startTime: 1412860569318[\r][\n]"
2014-10-09 15:16:09,594 [bio-8080-exec-3] DEBUG header                        
- >> "org.restlet.http.version: 1.1[\r][\n]"
2014-10-09 15:16:09,594 [bio-8080-exec-3] DEBUG header                        
- >> "User-Agent: Jakarta Commons-HttpClient/3.0.1[\r][\n]"
2014-10-09 15:16:09,594 [bio-8080-exec-3] DEBUG header                        
- >> "Host: localhost:8012[\r][\n]"
2014-10-09 15:16:09,594 [bio-8080-exec-3] DEBUG header                        
- >> "Content-Length: 262[\r][\n]"
2014-10-09 15:16:09,594 [bio-8080-exec-3] DEBUG header                        
- >> "Content-Type: application/json[\r][\n]"
2014-10-09 15:16:09,594 [bio-8080-exec-3] DEBUG header                        
- >> "[\r][\n]"
2014-10-09 15:16:09,594 [bio-8080-exec-3] DEBUG content                       
- >> "<?xml version="1.0" encoding="iso-8859-1"?>[\r][\n]"
2014-10-09 15:16:09,595 [bio-8080-exec-3] DEBUG content                       
- >> "<identificationRequest [\r][\n]"
2014-10-09 15:16:09,595 [bio-8080-exec-3] DEBUG content                       
- >> "[0x9]v="1.0"[\r][\n]"
2014-10-09 15:16:09,595 [bio-8080-exec-3] DEBUG content                       
- >> "[0x9]mgrUserID="toto" [\r][\n]"
2014-10-09 15:16:09,595 [bio-8080-exec-3] DEBUG content                       
- >> "[0x9]clUserID="toto" [\r][\n]"
2014-10-09 15:16:09,595 [bio-8080-exec-3] DEBUG content                       
- >> "[0x9]clMediaID="WEB"  [\r][\n]"
2014-10-09 15:16:09,595 [bio-8080-exec-3] DEBUG content                       
- >> "[0x9]pwd="toto" [\r][\n]"
2014-10-09 15:16:09,595 [bio-8080-exec-3] DEBUG content                       
- >> "[0x9]mgrMediaID="OMS" [\r][\n]"
2014-10-09 15:16:09,595 [bio-8080-exec-3] DEBUG content                       
- >> "[0x9]mgrUserIP="127.0.0.1">[\r][\n]"
2014-10-09 15:16:09,595 [bio-8080-exec-3] DEBUG content                       
- >> "</identificationRequest>[\r][\n]"
2014-10-09 15:16:09,595 [bio-8080-exec-3] DEBUG content                       
- >> "[\r][\n]"
2014-10-09 15:16:09,595 [bio-8080-exec-3] DEBUG EntityEnclosingMethod         
- Request body sent
2014-10-09 15:16:09,859 [bio-8080-exec-3] DEBUG header                        
- << "HTTP/1.1 200 OK[\r][\n]"
2014-10-09 15:16:09,862 [bio-8080-exec-3] DEBUG header                        
- << "Server: Apache-Coyote/1.1[\r][\n]"
2014-10-09 15:16:09,862 [bio-8080-exec-3] DEBUG header                        
- << "Set-Cookie:
JSESSIONID=D233B36C21D95CBE41CA132DE63B73B5.CA571B35CD035C70CD;
Path=/[\r][\n]"
2014-10-09 15:16:09,862 [bio-8080-exec-3] DEBUG header                        
- << "Content-Type: text/xml[\r][\n]"
2014-10-09 15:16:09,862 [bio-8080-exec-3] DEBUG header                        
- << "Content-Length: 105[\r][\n]"
2014-10-09 15:16:09,862 [bio-8080-exec-3] DEBUG header                        
- << "Date: Thu, 09 Oct 2014 13:16:09 GMT[\r][\n]"
2014-10-09 15:16:09,891 [bio-8080-exec-3] DEBUG HttpMethodBase                
- Cookie accepted: "$Version=0;
JSESSIONID=D233B36C21D95CBE41CA132DE63B73B5.CA571B35CD035C70CD; $Path=/"
2014-10-09 15:16:09,893 [bio-8080-exec-3] DEBUG HttpProducer                  
- Http responseCode: 200
2014-10-09 15:16:09,893 [bio-8080-exec-3] DEBUG content                       
- << "<?xml version="1.0" encoding="iso-8859-1"?><identificationResponse
v="1.0" userID="toto" status="0"/>"
2014-10-09 15:16:09,894 [bio-8080-exec-3] DEBUG HttpMethodBase                
- Resorting to protocol version default close connection policy
2014-10-09 15:16:09,895 [bio-8080-exec-3] DEBUG HttpMethodBase                
- Should NOT close connection, using HTTP/1.1
2014-10-09 15:16:09,895 [bio-8080-exec-3] DEBUG HttpConnection                
- Releasing connection back to connection manager.
2014-10-09 15:16:09,895 [bio-8080-exec-3] DEBUG
iThreadedHttpConnectionManager - Freeing connection,
hostConfig=HostConfiguration[host=http://localhost:8012]
2014-10-09 15:16:09,896 [bio-8080-exec-3] DEBUG IdleConnectionHandler         
- Adding connection at: 1412860569896
2014-10-09 15:16:09,896 [bio-8080-exec-3] DEBUG
iThreadedHttpConnectionManager - Notifying no-one, there are no waiting
threads
2014-10-09 15:16:09,897 [bio-8080-exec-3] INFO  Tracer                        
- ID-L82680-58528-1412860563831-0-2 >>> (RS_RestletDemo)
http://distantserver:8012/test/identification.xml?bridgeEndpoint=true -->
convertBodyTo[java.lang.String] <<< Pattern:InOut,
Headers:{Set-Cookie=JSESSIONID=D233B36C21D95CBE41CA132DE63B73B5.CA571B35CD035C70CD;
Path=/, CamelHttpResponseCode=200, org.restlet.http.version=1.1,
CamelRestletResponse=HTTP/1.1 - OK (200) - The request has succeeded,
Server=Apache-Coyote/1.1, Content-Length=105, CamelHttpMethod=POST,
CamelHttpUri=http://localhost:8080/wfs-rest/api/identification,
CamelRestletRequest=POST http://localhost:8080/wfs-rest/api/identification
HTTP/1.1, Date=Thu, 09 Oct 2014 13:16:09 GMT,
breadcrumbId=ID-L82680-58528-1412860563831-0-1,
org.restlet.startTime=1412860569318, org.restlet.http.headers=[[host:
localhost:8080], [connection: keep-alive], [content-length: 77],
[cache-control: no-cache], [origin:
chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop], [content-type:
application/json], [user-agent: Mozilla/5.0 (Windows NT 6.1; WOW64)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36],
[postman-token: eb6c491c-b940-05a2-4409-47fbf6139644], [accept: */*],
[accept-encoding: gzip,deflate], [accept-language:
fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4], [cookie:
JSESSIONID=099AEDE2231A37E97E62E92986FE7481.9DFE950A9AAAD24F9A]],
Content-Type=text/xml},
BodyType:org.apache.camel.converter.stream.CachedOutputStream.WrappedInputStream,
Body:[Body is instance of java.io.InputStream]
2014-10-09 15:16:09,898 [bio-8080-exec-3] INFO  Tracer                        
- ID-L82680-58528-1412860563831-0-2 >>> (RS_RestletDemo)
convertBodyTo[java.lang.String] -->
marshal[org.apache.camel.dataformat.xmljson.XmlJsonDataFormat@1a10e12] <<<
Pattern:InOut, Headers:{Content-Length=105,
Set-Cookie=JSESSIONID=D233B36C21D95CBE41CA132DE63B73B5.CA571B35CD035C70CD;
Path=/, CamelHttpResponseCode=200, Content-Type=text/xml,
Server=Apache-Coyote/1.1, CamelRestletResponse=HTTP/1.1 - OK (200) - The
request has succeeded, org.restlet.startTime=1412860569318,
breadcrumbId=ID-L82680-58528-1412860563831-0-1, CamelHttpMethod=POST,
CamelHttpUri=http://localhost:8080/wfs-rest/api/identification,
CamelRestletRequest=POST http://localhost:8080/wfs-rest/api/identification
HTTP/1.1, Date=Thu, 09 Oct 2014 13:16:09 GMT, org.restlet.http.version=1.1,
org.restlet.http.headers=[[host: localhost:8080], [connection: keep-alive],
[content-length: 77], [cache-control: no-cache], [origin:
chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop], [content-type:
application/json], [user-agent: Mozilla/5.0 (Windows NT 6.1; WOW64)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36],
[postman-token: eb6c491c-b940-05a2-4409-47fbf6139644], [accept: */*],
[accept-encoding: gzip,deflate], [accept-language:
fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4], [cookie:
JSESSIONID=099AEDE2231A37E97E62E92986FE7481.9DFE950A9AAAD24F9A]]},
BodyType:String, Body:<?xml version="1.0"
encoding="iso-8859-1"?><identificationResponse v="1.0" userID="toto"
status="0"/>
2014-10-09 15:16:09,943 [bio-8080-exec-3] INFO  XMLSerializer                 
- Using default type string
2014-10-09 15:16:10,012 [bio-8080-exec-3] DEBUG DefaultRestletBinding         
- Populate Restlet response from exchange body: [123, 34, 105, 100, 101,
110, 116, 105, 102, 105, 99, 97, 116, 105, 111, 110, 82, 101, 115, 112, 111,
110, 115, 101, 34, 58, 123, 34, 64, 118, 34, 58, 34, 49, 46, 48, 34, 44, 34,
64, 117, 115, 101, 114, 73, 68, 34, 58, 34, 49, 57, 51, 49, 51, 54, 56, 57,
34, 44, 34, 64, 115, 116, 97, 116, 117, 115, 34, 58, 34, 48, 34, 125, 125]
oct. 09, 2014 3:16:10 PM org.restlet.engine.log.LogFilter afterHandle
INFOS: 2014-10-09	15:16:10	127.0.0.1	-	127.0.0.1	8080	POST
/wfs-rest/api/identification	-	200	105	77	694	http://localhost:8080
Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/37.0.2062.124 Safari/537.36	-


Antoine.




--
View this message in context: http://camel.465427.n5.nabble.com/Http-bridgeEndpoint-to-proxy-a-distant-server-tp5757448.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Http bridgeEndpoint to proxy a distant server

Posted by Charles Moulliard <ch...@gmail.com>.
Hi Antoine,

Add a beanProcessor (where in the code you can put a breakpoint) after the
HTTP endpoint calling your service and before the transform so you will be
able to check the objects present in the exchange.

Regards,


On Fri, Oct 10, 2014 at 1:06 PM, antb59 <an...@gmail.com> wrote:

> Hello,
>
> After checks, it seems that the trace you mentionned is not an error.
>
> If I do a simple proxy just like in this example :
>
> http://camel.apache.org/how-to-use-camel-as-a-http-proxy-between-a-client-and-server.html
>
>         <route id="Identification">
>                 <from uri="restlet:/identification?restletMethod=POST" />
>                 <to uri="
> http://localhost:8012/identification.xml?bridgeEndpoint=true" />
>         </route>
>
> The trace you mentionned is present in DEBUG. In this case the http request
> is correctly processed and the restlet returns the result to the user.
>
>
> The fact is I don't manage to manipulate the distant server response.
>
> The following configuration works :
>
>         <route id="Identification">
>                 <from uri="restlet:/identification?restletMethod=POST" />
>                 <to uri="
> http://localhost:8012/identification.xml?bridgeEndpoint=true" />
>                 <convertBodyTo type="java.lang.String"/>
>         </route>
>
> => return of restlet :
> <?xml version="1.0" encoding="iso-8859-1"?><identificationResponse
> status="0" />
>
> The following configuration doesn't work :
>
>         <route id="Identification">
>                 <from uri="restlet:/identification?restletMethod=POST" />
>                 <to uri="
> http://localhost:8012/identification.xml?bridgeEndpoint=true" />
>                 <convertBodyTo type="java.lang.String"/>
>                 <marshal ref="xmljson" />
>         </route>
>
> => No return from restlet, the response is hanging until timeout
>
> With the following route, the result seems to be truncated :
>
>         <route id="Identification">
>                 <from uri="restlet:/identification?restletMethod=POST" />
>                 <to uri="
> http://localhost:8012/identification.xml?bridgeEndpoint=true" />
>                 <transform>
>                         <simple>Test : ${bodyAs(String)}</simple>
>                 </transform>
>         </route>
>
> => Return from the restlet :
> Test : <?xml version="1.0" encoding="iso-8859-1"?><identificationResponse
> statu
>
> The end of the response seems to be truncated.
>
> Maybe my problem is linked to InputStream return by the distant server ?
> How can I solve this using only DSL ?
>
> Regards,
> Antoine.
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Http-bridgeEndpoint-to-proxy-a-distant-server-tp5757448p5757474.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Charles Moulliard
Apache Committer / Architect @RedHat
Twitter : @cmoulliard | Blog :  http://cmoulliard.github.io

Re: Http bridgeEndpoint to proxy a distant server

Posted by antb59 <an...@gmail.com>.
Hello,

After checks, it seems that the trace you mentionned is not an error.

If I do a simple proxy just like in this example :
http://camel.apache.org/how-to-use-camel-as-a-http-proxy-between-a-client-and-server.html

	<route id="Identification">
		<from uri="restlet:/identification?restletMethod=POST" />
		<to uri="http://localhost:8012/identification.xml?bridgeEndpoint=true" />
	</route>

The trace you mentionned is present in DEBUG. In this case the http request
is correctly processed and the restlet returns the result to the user.


The fact is I don't manage to manipulate the distant server response.

The following configuration works :

	<route id="Identification">
		<from uri="restlet:/identification?restletMethod=POST" />
		<to uri="http://localhost:8012/identification.xml?bridgeEndpoint=true" />
		<convertBodyTo type="java.lang.String"/>
	</route>

=> return of restlet : 
<?xml version="1.0" encoding="iso-8859-1"?><identificationResponse
status="0" />

The following configuration doesn't work :

	<route id="Identification">
		<from uri="restlet:/identification?restletMethod=POST" />
		<to uri="http://localhost:8012/identification.xml?bridgeEndpoint=true" />
		<convertBodyTo type="java.lang.String"/>
		<marshal ref="xmljson" />
	</route>

=> No return from restlet, the response is hanging until timeout

With the following route, the result seems to be truncated :

	<route id="Identification">
		<from uri="restlet:/identification?restletMethod=POST" />
		<to uri="http://localhost:8012/identification.xml?bridgeEndpoint=true" />
		<transform>
			<simple>Test : ${bodyAs(String)}</simple>
		</transform>
	</route>

=> Return from the restlet :
Test : <?xml version="1.0" encoding="iso-8859-1"?><identificationResponse
statu

The end of the response seems to be truncated.

Maybe my problem is linked to InputStream return by the distant server ?
How can I solve this using only DSL ?

Regards,
Antoine.




--
View this message in context: http://camel.465427.n5.nabble.com/Http-bridgeEndpoint-to-proxy-a-distant-server-tp5757448p5757474.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Http bridgeEndpoint to proxy a distant server

Posted by antb59 <an...@gmail.com>.
Hello Charles,

Thanks for pointing me this error, I missed it !

So it seems that the folllowing line in my route is raising the
TypeConvertion issue.
<to uri="http://distantserver:8012/test/identification.xml" /> 

Could you explain to me why Camel is trying to convert an HttpMethods to a
String in my case ?

Thank you again for your support.

Regards,
Antoine.



--
View this message in context: http://camel.465427.n5.nabble.com/Http-bridgeEndpoint-to-proxy-a-distant-server-tp5757448p5757462.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Http bridgeEndpoint to proxy a distant server

Posted by Charles Moulliard <ch...@gmail.com>.
Hi Antoine,

There is TypeConvertion issue :

DEBUG DefaultTypeConverter
- Promoting fallback type converter as a known type converter to convert
from: org.apache.camel.component.http.HttpMethods to: java.lang.String for
the fallback converter:
org.apache.camel.impl.converter.EnumTypeConverter@809a88

This is what you have to fix. More info about TypeConverter here :
http://camel.apache.org/type-converter.html

Regards,


On Thu, Oct 9, 2014 at 3:44 PM, antb59 <an...@gmail.com> wrote:

> Hello,
>
> I'm trying to build some kind of Rest proxy with Camel :
>  1 - A restlet endpoint will receive POST request with JSON body
>  2 - The body will be transformed into a XML request using freemarker
>  3 - The xml request will be sent to a distant HTTP server
>  4 - The HTTP server will send a XML response in a synchronous way
>  5 - The response will be transformed in JSON using freemarker
>  6 - The JSON response will be forwarded to the client
>
> Steps 1 to 4 works well, without a line of code !
> But I'm facing some troubles with steps 4 : the HTTP distant server answer
> is an InputStream, and I'm not able to transform it.
>
> Here is my context configuration :
>
>         <bean id="RestletComponent" class="org.restlet.Component" />
>
>         <bean id="RestletComponentService"
> class="org.apache.camel.component.restlet.RestletComponent">
>                 <constructor-arg index="0">
>                         <ref bean="RestletComponent" />
>                 </constructor-arg>
>         </bean>
>
>         <camelContext xmlns="http://camel.apache.org/schema/spring"
> trace="true">
>
>                 <route id="RS_RestletDemo">
>                         <from
> uri="restlet:/identification?restletMethod=POST" />
>                         <transform>
>                                 <simple>${bodyAs(String)}</simple>
>                         </transform>
>                         <to uri="freemarker:identification.xml"/>
>                         <setHeader headerName="CamelHttpMethod">
>                                 <constant>POST</constant>
>                         </setHeader>
>                         <to uri="
> http://distantserver:8012/test/identification.xml" />
>                         <convertBodyTo type="java.lang.String"/>
>                 </route>
>         </camelContext>
>
>
> This configuration works (steps 5-6 are not present).
> However if I add lines below convertBodyTo, the request to the restlet
> server hangs and never answer :
>
> <route id="RS_RestletDemo">
>         <from uri="restlet:/identification?restletMethod=POST" />
>         <transform>
>                 <simple>${bodyAs(String)}</simple>
>         </transform>
>         <to uri="freemarker:identification.xml"/>
>         <setHeader headerName="CamelHttpMethod">
>                 <constant>POST</constant>
>         </setHeader>
>         <to uri="http://distantserver:8012/test/identification.xml" />
>         <convertBodyTo type="java.lang.String"/>
>         <marshal ref="xmljsonWithOptions"/>
> </route>
>
> When I check the logs, the JSON conversion seems to work fine.
> I checked samples about http proxy in camel there :
>
> http://camel.apache.org/how-to-use-camel-as-a-http-proxy-between-a-client-and-server.html
>
> http://blog.sedona.fr/2013/03/introduction-aux-eips-suite-mise-en-pratique-avec-apache-camel/
>
> But I can't found a sample where the message out of the distant server is
> used and converted before returning to client.
>
> Is it possible ?
>
> Here are the logs when request is hanging and never returned :
>
> 2014-10-09 15:16:09,319 [bio-8080-exec-3] DEBUG MethodBasedRouter
> - MethodRouter (/identification) received request method: POST
> 2014-10-09 15:16:09,319 [bio-8080-exec-3] DEBUG RestletConsumer
> - Consumer restlet handle request method: POST
> 2014-10-09 15:16:09,324 [bio-8080-exec-3] DEBUG DefaultRestletBinding
> - Populate exchange from Restlet request header: org.restlet.http.version
> value: 1.1
> 2014-10-09 15:16:09,324 [bio-8080-exec-3] DEBUG DefaultRestletBinding
> - Populate exchange from Restlet request header: org.restlet.http.headers
> value: [[host: localhost:8080], [connection: keep-alive], [content-length:
> 77], [cache-control: no-cache], [origin:
> chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop], [content-type:
> application/json], [user-agent: Mozilla/5.0 (Windows NT 6.1; WOW64)
> AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36],
> [postman-token: eb6c491c-b940-05a2-4409-47fbf6139644], [accept: */*],
> [accept-encoding: gzip,deflate], [accept-language:
> fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4], [cookie:
> JSESSIONID=099AEDE2231A37E97E62E92986FE7481.9DFE950A9AAAD24F9A]]
> 2014-10-09 15:16:09,324 [bio-8080-exec-3] DEBUG DefaultRestletBinding
> - Populate exchange from Restlet request header: org.restlet.startTime
> value: 1412860569318
> 2014-10-09 15:16:09,347 [bio-8080-exec-3] INFO  Tracer
> - ID-L82680-58528-1412860563831-0-2 >>> (RS_RestletDemo)
> from(/identification?restletMethods=POST) --> transform[Simple:
> ${bodyAs(String)}] <<< Pattern:InOut, Headers:{CamelRestletRequest=POST
> http://localhost:8080/wfs-rest/api/identification HTTP/1.1,
> CamelRestletResponse=HTTP/1.1 - OK (200) - The request has succeeded,
> org.restlet.http.version=1.1, org.restlet.startTime=1412860569318,
> org.restlet.http.headers=[[host: localhost:8080], [connection: keep-alive],
> [content-length: 77], [cache-control: no-cache], [origin:
> chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop], [content-type:
> application/json], [user-agent: Mozilla/5.0 (Windows NT 6.1; WOW64)
> AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36],
> [postman-token: eb6c491c-b940-05a2-4409-47fbf6139644], [accept: */*],
> [accept-encoding: gzip,deflate], [accept-language:
> fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4], [cookie:
> JSESSIONID=099AEDE2231A37E97E62E92986FE7481.9DFE950A9AAAD24F9A]],
> CamelHttpMethod=POST,
> CamelHttpUri=http://localhost:8080/wfs-rest/api/identification,
> Content-Type=application/json,
> breadcrumbId=ID-L82680-58528-1412860563831-0-1},
> BodyType:org.apache.camel.converter.stream.InputStreamCache, Body:[Body is
> instance of org.apache.camel.StreamCache]
> 2014-10-09 15:16:09,351 [bio-8080-exec-3] DEBUG DefaultListableBeanFactory
> - Creating instance of bean
> 'org.apache.camel.language.simple.SimpleLanguage'
> 2014-10-09 15:16:09,351 [bio-8080-exec-3] DEBUG DefaultListableBeanFactory
> - Finished creating instance of bean
> 'org.apache.camel.language.simple.SimpleLanguage'
> 2014-10-09 15:16:09,366 [bio-8080-exec-3] INFO  Tracer
> - ID-L82680-58528-1412860563831-0-2 >>> (RS_RestletDemo) transform[Simple:
> ${bodyAs(String)}] --> freemarker://identification.xml <<< Pattern:InOut,
> Headers:{org.restlet.http.headers=[[host: localhost:8080], [connection:
> keep-alive], [content-length: 77], [cache-control: no-cache], [origin:
> chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop], [content-type:
> application/json], [user-agent: Mozilla/5.0 (Windows NT 6.1; WOW64)
> AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36],
> [postman-token: eb6c491c-b940-05a2-4409-47fbf6139644], [accept: */*],
> [accept-encoding: gzip,deflate], [accept-language:
> fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4], [cookie:
> JSESSIONID=099AEDE2231A37E97E62E92986FE7481.9DFE950A9AAAD24F9A]],
> CamelHttpUri=http://localhost:8080/wfs-rest/api/identification,
> CamelRestletRequest=POST http://localhost:8080/wfs-rest/api/identification
> HTTP/1.1, org.restlet.http.version=1.1,
> org.restlet.startTime=1412860569318,
> CamelHttpMethod=POST, Content-Type=application/json,
> breadcrumbId=ID-L82680-58528-1412860563831-0-1,
> CamelRestletResponse=HTTP/1.1 - OK (200) - The request has succeeded},
> BodyType:String, Body:{
>         "login" : "toto",
>         "password" : "a743edbeb4610c5f793508df0c3f0711"
> }
>
> 2014-10-09 15:16:09,367 [bio-8080-exec-3] DEBUG SendProcessor
> - >>>> Endpoint[freemarker://identification.xml] Exchange[Message: {
>         "login" : "toto",
>         "password" : "toto"
> }
> ]
> 2014-10-09 15:16:09,368 [bio-8080-exec-3] DEBUG FreemarkerEndpoint
> - Freemarker is evaluating identification.xml using context:
> {response=Message: {
>         "login" : "toto",
>         "password" : "toto"
> }
> , headers={org.restlet.http.headers=[[host: localhost:8080], [connection:
> keep-alive], [content-length: 77], [cache-control: no-cache], [origin:
> chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop], [content-type:
> application/json], [user-agent: Mozilla/5.0 (Windows NT 6.1; WOW64)
> AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36],
> [postman-token: eb6c491c-b940-05a2-4409-47fbf6139644], [accept: */*],
> [accept-encoding: gzip,deflate], [accept-language:
> fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4], [cookie:
> JSESSIONID=099AEDE2231A37E97E62E92986FE7481.9DFE950A9AAAD24F9A]],
> CamelHttpUri=http://localhost:8080/wfs-rest/api/identification,
> CamelRestletRequest=POST http://localhost:8080/wfs-rest/api/identification
> HTTP/1.1, org.restlet.http.version=1.1,
> org.restlet.startTime=1412860569318,
> CamelHttpMethod=POST, Content-Type=application/json,
> breadcrumbId=ID-L82680-58528-1412860563831-0-1,
> CamelRestletResponse=HTTP/1.1 - OK (200) - The request has succeeded},
> body={
>         "login" : "toto",
>         "password" : "toto"
> }
> , camelContext=SpringCamelContext(camel-1) with spring id
> org.springframework.web.context.WebApplicationContext:/wfs-rest,
> request=Message: {
>         "login" : "toto",
>         "password" : "toto"
> }
> , in=Message: {
>         "login" : "toto",
>         "password" : "toto"
> }
> , exchange=Exchange[Message: {
>         "login" : "toto",
>         "password" : "toto"
> }
> ], out=Message: {
>         "login" : "toto",
>         "password" : "toto"
> }
> }
> 2014-10-09 15:16:09,376 [bio-8080-exec-3] DEBUG cache
> - Could not find template in cache, creating new one;
> id=["identification.xml"["fr_FR",Cp1252,parsed] ]
> 2014-10-09 15:16:09,380 [bio-8080-exec-3] DEBUG cache
> - Compiling FreeMarker template "identification.xml"["fr_FR",Cp1252,parsed]
> from "file:/D:/wfs-rest-camel/WEB-INF/classes/identification.xml"
> 2014-10-09 15:16:09,528 [bio-8080-exec-3] INFO  Tracer
> - ID-L82680-58528-1412860563831-0-2 >>> (RS_RestletDemo)
> freemarker://identification.xml --> setHeader[CamelHttpMethod] <<<
> Pattern:InOut, Headers:{org.restlet.http.headers=[[host: localhost:8080],
> [connection: keep-alive], [content-length: 77], [cache-control: no-cache],
> [origin: chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop],
> [content-type: application/json], [user-agent: Mozilla/5.0 (Windows NT 6.1;
> WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124
> Safari/537.36], [postman-token: eb6c491c-b940-05a2-4409-47fbf6139644],
> [accept: */*], [accept-encoding: gzip,deflate], [accept-language:
> fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4], [cookie:
> JSESSIONID=099AEDE2231A37E97E62E92986FE7481.9DFE950A9AAAD24F9A]],
> CamelHttpUri=http://localhost:8080/wfs-rest/api/identification,
> CamelRestletRequest=POST http://localhost:8080/wfs-rest/api/identification
> HTTP/1.1, org.restlet.http.version=1.1,
> org.restlet.startTime=1412860569318,
> CamelHttpMethod=POST, Content-Type=application/json,
> breadcrumbId=ID-L82680-58528-1412860563831-0-1,
> CamelRestletResponse=HTTP/1.1 - OK (200) - The request has succeeded},
> BodyType:String, Body:<?xml version="1.0" encoding="iso-8859-1"?>
> <identificationRequest
>         v="1.0"
>         mgrUserID="toto"
>         clUserID="toto"
>         clMediaID="WEB"
>         pwd="toto"
>         mgrMediaID="OMS"
>         mgrUserIP="127.0.0.1">
> </identificationRequest>
>
>
> 2014-10-09 15:16:09,529 [bio-8080-exec-3] INFO  Tracer
> - ID-L82680-58528-1412860563831-0-2 >>> (RS_RestletDemo)
> setHeader[CamelHttpMethod] -->
> http://distantserver:8012/test/identification.xml?bridgeEndpoint=true <<<
> Pattern:InOut, Headers:{org.restlet.http.headers=[[host: localhost:8080],
> [connection: keep-alive], [content-length: 77], [cache-control: no-cache],
> [origin: chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop],
> [content-type: application/json], [user-agent: Mozilla/5.0 (Windows NT 6.1;
> WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124
> Safari/537.36], [postman-token: eb6c491c-b940-05a2-4409-47fbf6139644],
> [accept: */*], [accept-encoding: gzip,deflate], [accept-language:
> fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4], [cookie:
> JSESSIONID=099AEDE2231A37E97E62E92986FE7481.9DFE950A9AAAD24F9A]],
> CamelRestletResponse=HTTP/1.1 - OK (200) - The request has succeeded,
> CamelHttpMethod=POST,
> CamelHttpUri=http://localhost:8080/wfs-rest/api/identification,
> CamelRestletRequest=POST http://localhost:8080/wfs-rest/api/identification
> HTTP/1.1, breadcrumbId=ID-L82680-58528-1412860563831-0-1,
> Content-Type=application/json, org.restlet.startTime=1412860569318,
> org.restlet.http.version=1.1}, BodyType:String, Body:<?xml version="1.0"
> encoding="iso-8859-1"?>
> <identificationRequest
>         v="1.0"
>         mgrUserID="toto"
>         clUserID="toto"
>         clMediaID="WEB"
>         pwd="toto"
>         mgrMediaID="OMS"
>         mgrUserIP="127.0.0.1">
> </identificationRequest>
>
>
> 2014-10-09 15:16:09,529 [bio-8080-exec-3] DEBUG SendProcessor
> - >>>>
> Endpoint[
> http://distantserver:8012/test/identification.xml?bridgeEndpoint=true]
> Exchange[Message: <?xml version="1.0" encoding="iso-8859-1"?>
> <identificationRequest
>         v="1.0"
>         mgrUserID="toto"
>         clUserID="toto"
>         clMediaID="WEB"
>         pwd="toto"
>         mgrMediaID="OMS"
>         mgrUserIP="127.0.0.1">
> </identificationRequest>
>
> ]
> 2014-10-09 15:16:09,543 [bio-8080-exec-3] DEBUG DefaultTypeConverter
> - Promoting fallback type converter as a known type converter to convert
> from: org.apache.camel.component.http.HttpMethods to: java.lang.String for
> the fallback converter:
> org.apache.camel.impl.converter.EnumTypeConverter@809a88
> 2014-10-09 15:16:09,571 [bio-8080-exec-3] DEBUG HttpProducer
> - Executing http POST method:
> http://distantserver:8012/test/identification.xml?bridgeEndpoint=true
> 2014-10-09 15:16:09,578 [bio-8080-exec-3] DEBUG
> iThreadedHttpConnectionManager - HttpConnectionManager.getConnection:
> config = HostConfiguration[host=http://localhost:8012], timeout = 0
> 2014-10-09 15:16:09,579 [bio-8080-exec-3] DEBUG
> iThreadedHttpConnectionManager - Allocating new connection,
> hostConfig=HostConfiguration[host=http://localhost:8012]
> 2014-10-09 15:16:09,583 [bio-8080-exec-3] DEBUG HttpConnection
> - Open connection to localhost:8012
> 2014-10-09 15:16:09,586 [bio-8080-exec-3] DEBUG header
> - >> "POST /useraccount/identification.xml HTTP/1.1[\r][\n]"
> 2014-10-09 15:16:09,586 [bio-8080-exec-3] DEBUG HttpMethodBase
> - Adding Host request header
> 2014-10-09 15:16:09,594 [bio-8080-exec-3] DEBUG header
> - >> "org.restlet.http.headers: [[host: localhost:8080], [connection:
> keep-alive], [content-length: 77], [cache-control: no-cache], [origin:
> chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop], [content-type:
> application/json], [user-agent: Mozilla/5.0 (Windows NT 6.1; WOW64)
> AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36],
> [postman-token: eb6c491c-b940-05a2-4409-47fbf6139644], [accept: */*],
> [accept-encoding: gzip,deflate], [accept-language:
> fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4], [cookie:
> JSESSIONID=099AEDE2231A37E97E62E92986FE7481.9DFE950A9AAAD24F9A]][\r][\n]"
> 2014-10-09 15:16:09,594 [bio-8080-exec-3] DEBUG header
> - >> "breadcrumbId: ID-L82680-58528-1412860563831-0-1[\r][\n]"
> 2014-10-09 15:16:09,594 [bio-8080-exec-3] DEBUG header
> - >> "org.restlet.startTime: 1412860569318[\r][\n]"
> 2014-10-09 15:16:09,594 [bio-8080-exec-3] DEBUG header
> - >> "org.restlet.http.version: 1.1[\r][\n]"
> 2014-10-09 15:16:09,594 [bio-8080-exec-3] DEBUG header
> - >> "User-Agent: Jakarta Commons-HttpClient/3.0.1[\r][\n]"
> 2014-10-09 15:16:09,594 [bio-8080-exec-3] DEBUG header
> - >> "Host: localhost:8012[\r][\n]"
> 2014-10-09 15:16:09,594 [bio-8080-exec-3] DEBUG header
> - >> "Content-Length: 262[\r][\n]"
> 2014-10-09 15:16:09,594 [bio-8080-exec-3] DEBUG header
> - >> "Content-Type: application/json[\r][\n]"
> 2014-10-09 15:16:09,594 [bio-8080-exec-3] DEBUG header
> - >> "[\r][\n]"
> 2014-10-09 15:16:09,594 [bio-8080-exec-3] DEBUG content
> - >> "<?xml version="1.0" encoding="iso-8859-1"?>[\r][\n]"
> 2014-10-09 15:16:09,595 [bio-8080-exec-3] DEBUG content
> - >> "<identificationRequest [\r][\n]"
> 2014-10-09 15:16:09,595 [bio-8080-exec-3] DEBUG content
> - >> "[0x9]v="1.0"[\r][\n]"
> 2014-10-09 15:16:09,595 [bio-8080-exec-3] DEBUG content
> - >> "[0x9]mgrUserID="toto" [\r][\n]"
> 2014-10-09 15:16:09,595 [bio-8080-exec-3] DEBUG content
> - >> "[0x9]clUserID="toto" [\r][\n]"
> 2014-10-09 15:16:09,595 [bio-8080-exec-3] DEBUG content
> - >> "[0x9]clMediaID="WEB"  [\r][\n]"
> 2014-10-09 15:16:09,595 [bio-8080-exec-3] DEBUG content
> - >> "[0x9]pwd="toto" [\r][\n]"
> 2014-10-09 15:16:09,595 [bio-8080-exec-3] DEBUG content
> - >> "[0x9]mgrMediaID="OMS" [\r][\n]"
> 2014-10-09 15:16:09,595 [bio-8080-exec-3] DEBUG content
> - >> "[0x9]mgrUserIP="127.0.0.1">[\r][\n]"
> 2014-10-09 15:16:09,595 [bio-8080-exec-3] DEBUG content
> - >> "</identificationRequest>[\r][\n]"
> 2014-10-09 15:16:09,595 [bio-8080-exec-3] DEBUG content
> - >> "[\r][\n]"
> 2014-10-09 15:16:09,595 [bio-8080-exec-3] DEBUG EntityEnclosingMethod
> - Request body sent
> 2014-10-09 15:16:09,859 [bio-8080-exec-3] DEBUG header
> - << "HTTP/1.1 200 OK[\r][\n]"
> 2014-10-09 15:16:09,862 [bio-8080-exec-3] DEBUG header
> - << "Server: Apache-Coyote/1.1[\r][\n]"
> 2014-10-09 15:16:09,862 [bio-8080-exec-3] DEBUG header
> - << "Set-Cookie:
> JSESSIONID=D233B36C21D95CBE41CA132DE63B73B5.CA571B35CD035C70CD;
> Path=/[\r][\n]"
> 2014-10-09 15:16:09,862 [bio-8080-exec-3] DEBUG header
> - << "Content-Type: text/xml[\r][\n]"
> 2014-10-09 15:16:09,862 [bio-8080-exec-3] DEBUG header
> - << "Content-Length: 105[\r][\n]"
> 2014-10-09 15:16:09,862 [bio-8080-exec-3] DEBUG header
> - << "Date: Thu, 09 Oct 2014 13:16:09 GMT[\r][\n]"
> 2014-10-09 15:16:09,891 [bio-8080-exec-3] DEBUG HttpMethodBase
> - Cookie accepted: "$Version=0;
> JSESSIONID=D233B36C21D95CBE41CA132DE63B73B5.CA571B35CD035C70CD; $Path=/"
> 2014-10-09 15:16:09,893 [bio-8080-exec-3] DEBUG HttpProducer
> - Http responseCode: 200
> 2014-10-09 15:16:09,893 [bio-8080-exec-3] DEBUG content
> - << "<?xml version="1.0" encoding="iso-8859-1"?><identificationResponse
> v="1.0" userID="toto" status="0"/>"
> 2014-10-09 15:16:09,894 [bio-8080-exec-3] DEBUG HttpMethodBase
> - Resorting to protocol version default close connection policy
> 2014-10-09 15:16:09,895 [bio-8080-exec-3] DEBUG HttpMethodBase
> - Should NOT close connection, using HTTP/1.1
> 2014-10-09 15:16:09,895 [bio-8080-exec-3] DEBUG HttpConnection
> - Releasing connection back to connection manager.
> 2014-10-09 15:16:09,895 [bio-8080-exec-3] DEBUG
> iThreadedHttpConnectionManager - Freeing connection,
> hostConfig=HostConfiguration[host=http://localhost:8012]
> 2014-10-09 15:16:09,896 [bio-8080-exec-3] DEBUG IdleConnectionHandler
> - Adding connection at: 1412860569896
> 2014-10-09 15:16:09,896 [bio-8080-exec-3] DEBUG
> iThreadedHttpConnectionManager - Notifying no-one, there are no waiting
> threads
> 2014-10-09 15:16:09,897 [bio-8080-exec-3] INFO  Tracer
> - ID-L82680-58528-1412860563831-0-2 >>> (RS_RestletDemo)
> http://distantserver:8012/test/identification.xml?bridgeEndpoint=true -->
> convertBodyTo[java.lang.String] <<< Pattern:InOut,
>
> Headers:{Set-Cookie=JSESSIONID=D233B36C21D95CBE41CA132DE63B73B5.CA571B35CD035C70CD;
> Path=/, CamelHttpResponseCode=200, org.restlet.http.version=1.1,
> CamelRestletResponse=HTTP/1.1 - OK (200) - The request has succeeded,
> Server=Apache-Coyote/1.1, Content-Length=105, CamelHttpMethod=POST,
> CamelHttpUri=http://localhost:8080/wfs-rest/api/identification,
> CamelRestletRequest=POST http://localhost:8080/wfs-rest/api/identification
> HTTP/1.1, Date=Thu, 09 Oct 2014 13:16:09 GMT,
> breadcrumbId=ID-L82680-58528-1412860563831-0-1,
> org.restlet.startTime=1412860569318, org.restlet.http.headers=[[host:
> localhost:8080], [connection: keep-alive], [content-length: 77],
> [cache-control: no-cache], [origin:
> chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop], [content-type:
> application/json], [user-agent: Mozilla/5.0 (Windows NT 6.1; WOW64)
> AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36],
> [postman-token: eb6c491c-b940-05a2-4409-47fbf6139644], [accept: */*],
> [accept-encoding: gzip,deflate], [accept-language:
> fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4], [cookie:
> JSESSIONID=099AEDE2231A37E97E62E92986FE7481.9DFE950A9AAAD24F9A]],
> Content-Type=text/xml},
>
> BodyType:org.apache.camel.converter.stream.CachedOutputStream.WrappedInputStream,
> Body:[Body is instance of java.io.InputStream]
> 2014-10-09 15:16:09,898 [bio-8080-exec-3] INFO  Tracer
> - ID-L82680-58528-1412860563831-0-2 >>> (RS_RestletDemo)
> convertBodyTo[java.lang.String] -->
> marshal[org.apache.camel.dataformat.xmljson.XmlJsonDataFormat@1a10e12] <<<
> Pattern:InOut, Headers:{Content-Length=105,
> Set-Cookie=JSESSIONID=D233B36C21D95CBE41CA132DE63B73B5.CA571B35CD035C70CD;
> Path=/, CamelHttpResponseCode=200, Content-Type=text/xml,
> Server=Apache-Coyote/1.1, CamelRestletResponse=HTTP/1.1 - OK (200) - The
> request has succeeded, org.restlet.startTime=1412860569318,
> breadcrumbId=ID-L82680-58528-1412860563831-0-1, CamelHttpMethod=POST,
> CamelHttpUri=http://localhost:8080/wfs-rest/api/identification,
> CamelRestletRequest=POST http://localhost:8080/wfs-rest/api/identification
> HTTP/1.1, Date=Thu, 09 Oct 2014 13:16:09 GMT,
> org.restlet.http.version=1.1,
> org.restlet.http.headers=[[host: localhost:8080], [connection: keep-alive],
> [content-length: 77], [cache-control: no-cache], [origin:
> chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop], [content-type:
> application/json], [user-agent: Mozilla/5.0 (Windows NT 6.1; WOW64)
> AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36],
> [postman-token: eb6c491c-b940-05a2-4409-47fbf6139644], [accept: */*],
> [accept-encoding: gzip,deflate], [accept-language:
> fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4], [cookie:
> JSESSIONID=099AEDE2231A37E97E62E92986FE7481.9DFE950A9AAAD24F9A]]},
> BodyType:String, Body:<?xml version="1.0"
> encoding="iso-8859-1"?><identificationResponse v="1.0" userID="toto"
> status="0"/>
> 2014-10-09 15:16:09,943 [bio-8080-exec-3] INFO  XMLSerializer
> - Using default type string
> 2014-10-09 15:16:10,012 [bio-8080-exec-3] DEBUG DefaultRestletBinding
> - Populate Restlet response from exchange body: [123, 34, 105, 100, 101,
> 110, 116, 105, 102, 105, 99, 97, 116, 105, 111, 110, 82, 101, 115, 112,
> 111,
> 110, 115, 101, 34, 58, 123, 34, 64, 118, 34, 58, 34, 49, 46, 48, 34, 44,
> 34,
> 64, 117, 115, 101, 114, 73, 68, 34, 58, 34, 49, 57, 51, 49, 51, 54, 56, 57,
> 34, 44, 34, 64, 115, 116, 97, 116, 117, 115, 34, 58, 34, 48, 34, 125, 125]
> oct. 09, 2014 3:16:10 PM org.restlet.engine.log.LogFilter afterHandle
> INFOS: 2014-10-09       15:16:10        127.0.0.1       -       127.0.0.1
>      8080    POST
> /wfs-rest/api/identification    -       200     105     77      694
> http://localhost:8080
> Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko)
> Chrome/37.0.2062.124 Safari/537.36      -
>
>
> Antoine.
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Http-bridgeEndpoint-to-proxy-a-distant-server-tp5757448.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Charles Moulliard
Apache Committer / Architect @RedHat
Twitter : @cmoulliard | Blog :  http://cmoulliard.github.io