Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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
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
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
Hello,
Thanks for sharing your solution on forum. We have accepted your solution so that it allows others to see what has worked.
Best regards
Sabrina