Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[resolved] REST service proxy route

Hello!
Using Talend ESB, I want to proxy my REST service that is deployed, for example, on: http://hostnameA:8080/web_app to http://hostnameB:8085/web_app. That means, when I want to invoke the service (http://hostnameA:8080/web_app), I need to invoke them on: http://hostnameB:8085/web_app. It is just a simple proxy route.
I tried to do this using TOS and Talend ESB Studio, but without result. I tried something similar with Axis web services and works fine. My configuration for this case was:
Part of camel-config.xml file



address="http://proxy_hostname:8090/application/service/TokenService"
endpointName="s0683p000009M9p6.pngervice"
serviceName="s:TokenService"
wsdlURL="etc/TokenService.wsdl"
xmlns:s="http://tempo.intalio.org/security/tokenService/"/>


serviceName="serviceNS:TokenService"
endpointName="serviceNS0683p000009M9p6.pngervice" address="http://hostname:8080/axis2/services/TokenService">

....









Can someone help me?
Thanks in advance!

Labels (1)
  • Other

27 Replies
Anonymous
Not applicable
Author

Hi,
I have a another question..
If I have a job deployed on Talend ESB and the job calls a REST service using tREST or tHttpRequest component with 2 parameters (http://mashina:8080/applicationName/service/serviceName/process/{parameter1}/doctypes/{parameter2} - REST service endpoint), how can I invoke this job remotely from another application and read (or store) the response?
The KarafHostName is: localhost and KarafPort is: 18081
Thanks in advance!
Anonymous
Not applicable
Author

Hi ipercinlic, i'm also new to talend esb, camel, ... but i think you can solve this error "The error I get is: "Failed to create route cMessagingEndpoint_1: Route[[From[cxf://http://localhost:18081/alfresco/service/ab... because of Failed to resolve endpoint: cxf://http://localhost:18081/alfresco/service/abitecm/process?dataFormat=MESSAGE due to: No component found with scheme: cxf" (Error within Talend Route Builder when I press Run)" if you set the Camel component dependency to 'cxf' of the cMessagingEndpoint_1 component (Look under "Advenced settings" of the component cMessagingEndpoint_1). What i don't understand is that CXF has a special prefix for REST CXF Web Services (CXFRS, http://camel.apache.org/components.html) and how to import that prefix. May be you can import the prefix CXFRS when you import the corresponding .jar (Look under "Advenced settings" of the component cMessagingEndpoint_1 + "Use a custom component").
If i then try to run the example directly in the studio i get some "NoClassDefFoundError" errors. I believe that some camel / spring jars are missing in the studio runtime environment. But you can export the route and try to "import" these route in the talend esb (karaf). Unfortunately is in my example no proxy ws under the url http://KarafHostName:KarafPort/webserviceEndpoint reachable but may be you find a solution for this problem or it helps you to go further.
Good Luck!!!
Anonymous
Not applicable
Author

Hi frankEichholz, I tried your suggestion. When I run the route in the Talend ESB console, I get the error: "karaf@tesb> Failed to create Producer for endpoint: Endpoint. Reason: org.apache.camel.RuntimeCamelException: java.lang.NullPointerException".
I have a simple requirement - just want to expose my REST service on Talend ESB and I can't believe that there is no (simple) way to do it?! Or?
Talend Team?
Can anybody answer my question how can I run (call) a talend Job deployed on Talend ESB (as OSGi bundle for ESB) from another application?
Thanks in advance!
Anonymous
Not applicable
Author

Hi ipercinlic, me again.
I believe that you have to set some more cxf options.
bahaaldine mentioned that you have to set the wsdlURL option too.
"cxf://http://KarafHostName:KarafPort/webserviceEndpoint?wsdlURL=file:///pathToMyWSDL/file.wsdl&dataFormat=MESSAGE"
In my example (that currently does not work) i set the following options. I think it mainly depends on your wsdl.
"cxf://http://localhost:8080/webservices/TransportOrderService?wsdlURL=file:///C:/Temp/talend/TransportOrderService.wsdl&dataFormat=MESSAGE&portName={http://salt-solutions.de/logbase/transportorder/}TransportOrderServiceSoap"
Did you tried the "CXFRS" prefix and imported the corresponding jar ( http://camel.apache.org/cxfrs.html)?
Sorry that i can not help you more but as i said i'm new to the technology.
Anonymous
Not applicable
Author

hi,
For the Proxy Web server, can you try the following in ESB Studio
Create the HTTP listener for http://hostnameA:8080/web_app
1. Create a MessageEndpoint to listen for your HTTP requests (ProxyService)
2. In the Component panel, "Basic Settings" set the URL to "jetty:http://hostnameA:8080/web_app"
3. In the "Advanced Settings" click the + to add a dependency. Select 'jetty'
Forward request to http://hostnameB:8085/web_app (InternalService)
1. Create a MessageEndpoint
2. In the Component panel, under "Basic Settings" set the URL to http://hostnameB:8085/web_app
Create Proxy Service (Proxify)
You need to connect the inbound message and proxy the request to the service on hostnameB, _and_ connect the response messages on the outbound
1. Add a cProcessor
2. In Basic Settings of the Component add the following
//Print Request headers
System.out.println("> " + exchange.getIn().getHeaders());
//Create response message
exchange.getOut();

The first part is just for logging the request, so you can see something happening. The second line though is what connects the responses.

Certainly this works for me.
Hope this helps,
Ciaran
Anonymous
Not applicable
Author

Hi cdynes,
I tried your proposed solution, but when I invoke the REST service deployed on hostnameB I didn't get the response.
The expected response of my REST service is an url (in string format).
I tried with this configuration:
First cMessageEndpoint (HTTP listener) url: (Proxy service) "jetty:http://mashina:8085/alfresco/service/service_name/process/28/doctypes/banka.odobravanjeKredita.gotovinski.kreditniZahtjev"
Second cMessageEndpoint url: (Real web service)
"http://mashina:8080/alfresco/service/service_name/process/28/doctypes/banka.odobravanjeKredita.gotovinski.kreditniZahtjev?throwExceptionOnFailure=false"
The response that I get is: "Message: "
Look for the screenshots.
I checked the servers access logger and the request that commes to my service is fine:
"GET /alfresco/service/service_name/process/28/doctypes/banka.odobravanjeKredita.gotovinski.kreditniZahtjev HTTP/1.1" 200 119
I am using Jboss as an application server.
Anonymous
Not applicable
Author

Anonymous
Not applicable
Author

Hi cdynes, when I use the cSetHeader component to set the "Authorization" header (because my internal service needs an authentication), the proxy route works fine. In my test route, the cSetHeader component is configured with these parameters:
Header: "Authorization"
Language: Constant
Expression: "Basic value for username and password (fixed)"
How should I configure the cSetHeader component or the entire route to use the authorization parameters which are coming with a request?
I use the Firefox REST Client to test my route.
Thanks a lot for your help!
Anonymous
Not applicable
Author

Hi,
Good to hear!
Not sure I understand the setHeader() question. Is it that you need to add a new header for the internal REST service?

Ciaran
http://camel.apache.org/http.html
Anonymous
Not applicable
Author

Hi,
Because my REST Internal service needs the authentication, when I invoke the Proxy service I need also to send the authentication parameters (username, password). Using the Firefox REST client plugin, I've set the header "Authorization" and the corresponding value for username and password (Authorization=Basic someValue). When I want to invoke the service, I always get the dialog to enter the username and password although I have the "Authorization" header set.
But, when I use the cSetHeader component with these parameters:
Header: "Authorization"
Language: Constant
Expression: "Basic value for username and password (fixed)"
the service works fine.
I don't want to use fixed authentication parameters but parameters which I will send when I invoke the Proxy service. The question is - how can I proxy my authentication parameters to my REST internal service?