Highlighted
Five Stars

Dynamic CXF client parameters

Hello

We need to use 1 cxf client with dynamic parameters, for reuse purpose (we will have hundreds of WS to call and shall not use hundreds of cxf components). Context variables won't be sufficient, we need to use headers or properties.

 

I have a "normal" cxf component in a route, that works fine. I tried to cute&paste the generated java code into a cJavaDSLPRocessor , without changing anything, just set up "operationName" and "operationNamespace" before, but it fails.

Here is the code :

.toD(
"cxf://"
						+ 'the_url...'
						+ "?dataFormat=PAYLOAD"
						+ "&allowStreaming=false"
						+ "&wsdlURL="
						+ "http://uwstst01.ga.local:8080/wsdl/sgenvisvpa01.wsdl"
						+ "&serviceName="
						+ "{urn:uniface:applic:services:SGENVISVPA01}SGENVISVPA01Service"
						+ "&endpointName="
						+ "{urn:uniface:applic:services:SGENVISVPA01}SGENVISVPA01"
						+ "&defaultOperationNamespace="
						+ javax.xml.namespace.QName
								.valueOf(
										"{urn:uniface:applic:services:SGENVISVPA01}O_GET_XML")
								.getNamespaceURI()
						+ "&defaultOperationName="
						+ javax.xml.namespace.QName
								.valueOf(
										"{urn:uniface:applic:services:SGENVISVPA01}O_GET_XML")
								.getLocalPart()
						//+ "&headerFilterStrategy=#CXF_PAYLOAD_HEADER_FILTER"
)						

and the error :

org.apache.cxf.binding.soap.SoapFault: {USERVER:doSoapRequest:URBnewStatelessReq}Activation error: (-50, bad interface name: nil or empty)

How can we dynamically set a cxf client ?

 

Thank you

2 REPLIES
Moderator

Re: Dynamic CXF client parameters

Hello,

If we understand  your requirement very well, you are looking for a solution for dynamic invocation of web service in a ESB route?

Best regards

Sabrina

--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Five Stars

Re: Dynamic CXF client parameters

Hello

 

That's it. And I found the solution by myself :

 

in a cJavaDSLProcessor, copy and paste the code generated by Talend when we use a cCxf component :

.toD("cxf://${in.header.serviceURL}/?"
 + "dataFormat=PAYLOAD"
 + "&wsdlURL=..."
 + "&serviceName=...."
 + "&endpointName=..."
 + "&headerFilterStrategy=#CXF_PAYLOAD_HEADER_FILTER"		
)	

and the cxfHeaderFilterStrategy object is necessary to remove unwanted headers (from previous components) being passed to this cxf client. So in a cProcessor before the cJavaDSLProcessor we have to reproduce the code that TOS writes with a cxf component :

import org.apache.camel.component.cxf.common.header.*;
CxfHeaderFilterStrategy consumerSoapHeaderFilter = new CxfHeaderFilterStrategy();
consumerSoapHeaderFilter.setRelayHeaders(false);
registry.put("CXF_PAYLOAD_HEADER_FILTER", consumerSoapHeaderFilter);

Loko