This is using Camel 2.5.0
The route is quite simple. The starting point is the berth: //.../web/service/path, and the end of the route is http: // real-webservice-host / web / service / path . The problem I am facing is that when the remote web service is called, it is not called correctly.
In particular, the Content-Type header is not set when I use the bridgeEndpoint = true parameter on the http component. This causes my remote JAX-RS service to report an unsupported media Error 415. If I did not set the bridgeEndpoint parameter in the http component, then I need to go and configure the host header to point to the host that I already declared in the URI endpoint http.
What I would like to do would be:
from("jetty://host/path?matchOnUriPrefix=true").to("http://jaxrs-host/path")
And so that the HTTP method, headers and body are proxied to the remote endpoint.
I have a workaround for this, using a CXFRS bean that proxies the request:
@Path("/api/address") class AddressServiceProxy { @BeanProperty var targetUrl : String = _ @POST @Consumes(Array("application/xml")) @Produces(Array("application/xml")) @Path("/validation") def validate(in: InputStream) = { WebClient.create(targetUrl).post(in, classOf[String]) } }
And in spring config:
<bean id="addressServiceProxy" class="beans.AddressServiceProxy"> <property name="targetUrl" value="http://localhost:9000/api/address/validation"/> </bean>
And on the route:
from("jetty://http://0.0.0.0:8080/api/address?matchOnUriPrefix=true") .to("cxfbean:addressServiceProxy")
This approach works, but requires me to duplicate the JAX-RS endpoint I connect to. Is this the best way to do this, or is there a better approach?
source share