Camel Cxf: How can I change the namespace of my incoming message? - java

I have to change the namespace of the incoming messages to our webservice.
The consumer route looks like the following:
from("cxf:/myservice?serviceClass=myServiceClass")...
I've tried to add somehow an interceptor to this(parameter properties.in, properties.inInterceptors?), but I don't get it how to configure it to my route.
We are not configuring our cxf endpoints in spring so I have to solve it with additional parameters to the route.
I think an interceptor with the transformation feature mentioned in the cxf documentation is the right solution, but I was not able to configure it correctly.
How can I add an interceptor to the route?
Or is there another way to change the namespace of the incoming message?
kind regards,
soilworker

I've found a solution:
It is possible to say something like from(endpoint), so I've created an instance of CxfEndpoint and there I can set the cxfEndpointConfigurer.
In this configurer I can add an interceptor which removes the namespace(see transformation feature of cxf).
Maybe it also works somehow with the from(uri) syntax, but I don't know how.

Related

SPRING WS - route based on path

shall be possible to implement a soap webservice in Spring using #Endpoint annotation and route all message that are sent to a specific endpoint path to the same method?
I need the "behavior" already in place with #PayloadRoot or #SoapAction but "based" on endpoint path of the request.
Thanks in advance for support.

camel cxf uri option property.XXX to set http client timeout

It is possible to set client timeout via camel cxf uri options?
There is possibility to set cxf://someAddress?[options], where options can be properties.XXX.
It is possible to set somehow http client receive timeout?
I tried many of them (found in source code or via google), but no one works:
properties.com.sun.xml.ws.request.timeout
properties.com.sun.xml.internal.ws.request.timeout
properties.javax.xml.ws.client.receiveTimeout
properties.org.apache.cxf.jms.client.timeout
properties.org.apache.cxf.transport.http.async.SO_TIMEOUT
properties.conduit.client.ReceiveTimeout
properties.org.apache.cxf.transports.http.configuration.client.ReceiveTimeout
properties.http-conf:client.ReceiveTimeout
properties.HTTPClientPolicy.ReceiveTimeout
properties.org.apache.cxf.http.conduits.client.ReceiveTimeout
properties.org.apache.cxf.http.conduit.client.ReceiveTimeout
properties.org.apache.cxf.transports.http.configuration.HTTPClientPolicy.ReceiveTimeout
I know it is possible with sprinx xml, but I want it configurable via Talend context.
I also know that I can configure cxf client via CxfEndpointConfigurer bean, but camel 2.13 (upgrade is not possible) does not have configureClient method.
Thank you for answer.
As mentioned in this document you can configure HTTP Client to set timeout
<http-conf:conduit name="{http://apache.org/hello_world_soap_http}SoapPort.http-conduit">
<http-conf:client Connection="Keep-Alive"
MaxRetransmits="1"
AllowChunking="false"
ConnectionTimeout="60000"
ReceiveTimeout="60000"/>
</http-conf:conduit>
Maybe you need to use a RouteBuilder, use the java variable in your route.
Tyr do something like this:
from("cxf://someAddress?[options]?timeout=${yourTimeOutVariable}")

How to update camel properties externally?

Im developping non OSGI app and i need to update the values ​​of some properties used in camel routes (loaded BridgePropertyPlaceHolder).
So I thought:
To use Hawtio, the cool mangement console, in order update camel using JMX
Create a JMX MBean that will update the properties ..
I successfully create the MBean operations and call them using JMX, but I can't figure out how to update the camel routes that depends on these properties.
Is there a way to update the camel context externally?
Update:
Exemple of use case:when a remote server doesn't return response, we keep sending messages until we reach the max of unsuccessful attempt(messages without ack).
in camel we create a router pattern based on property loaded from file system.
This property can change occasionally, and we want to do this without restarting server, but the problem is that camel parse routes when starting context and i can't find no mean to update routes accordingly.
I am grateful for any proposal that could help:)
If you use Camel error handling to retry (redeliver) then you can use the retryWhile to keep retrying until you return false. This allows you to use java code etc, and that allows you to read the updated configuration option.
See more details at
http://camel.apache.org/exception-clause.html
And if you have a copy of Camel in Action book, see page 152
For what properties you want them to be dynamic.you can move those prop to some db and fetch them whenever you are reading.I think a redesign is required for your camel route.
Changing from endpoint parameters such as URLs etc., following procedure has to be used according to dynamic change endpoint camel:
stop the route
remove the route
change the endpoint
add the route
start the route
If the to endpoint has to be configurable, you may use the recipient list component. Here you may read properties from a database and/or from the filesystem using the appropriate Camel component.

Apache Camel and CXF: Mutlitple cxf:rsServer tags .. is this possible?

I have been making restful webservices with cxf and camel, i came accross a strange issue i dont know if this is a normal camel behaviour or what.
I have multiple classes exposed as restful services and mapped to different paths. First i had only cxf in my configuration and i could expose all classes as services simultaneously. Now that i am also using camel i have tags like this :
<camelcxf:rsServer id="rsServer1" address="/"
serviceClass="com.something.PoiSearchImpl">
</camelcxf:rsServer>
<camelcxf:rsServer id="rsServer2" address="/"
serviceClass="com.something.FooBarImpl">
</camelcxf:rsServer>
After this i have two routes which start from my cxf endpoints (described above ) and do some processing. Problem is only one of the service is working and other just doesnt gets invoked . it gives me 404 not found error. is this normal or i am missing something in my configuration?
Hi Sikorski,
Camel supports multiple cxf:rsServer. The problem with your approach is that both are mapped to an address '/'. This means that one of the servers is invoked.
Solution: You need to have unique address for each rsServer like below,
<camelcxf:rsServer id="rsServer1" address="/Bar" serviceClass="com.something.PoiSearchImpl">
</camelcxf:rsServer>
<camelcxf:rsServer id="rsServer2" address="/Foo" serviceClass="com.something.FooBarImpl">
</camelcxf:rsServer>

How to set a JMS message property within JAX-WS handler?

Is there any way to set a JMS message property within a JAX-WS handler? I am trying to set a custom property on the message, to be used by a MDB message selector.
I've tried setting the properties on the SOAPMessage within a SOAPHandler, but that doesn't work so I think those properties may be at a different level that does not apply to the message selector. And it doesn't work if I put the property in the BindingProvider's requestContext either.
For anyone reading this in the future: I was able to find a way to set JMS properties within a handler, but it appeared that the IBM generated MDB code was actually removing those properties. You may have to ditch the JMSListenerMDB in order to solve this issue.

Categories