Hello,

we need to build a proxy for an external request/reply SOAP web service. This 
same service must be offered both unmodified (namespace A) and with a different 
namespace B in the message schema. In both cases, some additional routing 
decisions must be taken.

For this, we have defined a CXF producer endpoint (using cxf:cxfEndpoint) in 
POJO message format that addresses the external service, using their WSDL 
(namespace A). The unmodified proxy on the consuming (input) side is also a CXF 
endpoint in POJO format, using the same WSDL. A route forwards (after some 
routing decisions) from this to the external service; this works.

To offer the service with a different namespaces, we tried several approaches 
without success.

One possibility seems to be a CXF consumer endpoint in MESSAGE message format 
that uses a StaxTransformationFeature to modify the namespace from B to A.
This endpoint uses a modified WSDL with namespace B instead of A. It must use 
MESSAGE, not POJO, because the WSDL file with the modified message namespace B 
would not match the transformed message in namespace A, which results in a 
parsing (JAXB) exception from CXF. We would like to send the transformed 
message to our own namespace A consumer endpoint to run through the normal 
routing decisions mentioned above. We cannot use the POJO endpoint because the 
message is in  MESSAGE format. So, we tried POSTing the message using the HTTP 
component:

<route id="cxf-admin-nsmap-route">
    <from uri="cxf:bean:fc-admin-service"/>
    <to 
uri="http://${fc.endpoint.host}:${fc.endpoint.port}/${fc.admin_cxf_nsmod.endpoint.path}"/>
</route>

This fails with

Invalid uri: /fc/admin. If you are forwarding/bridging http endpoints, then 
enable the bridgeEndpoint option on the endpoint: 
Endpoint[http://$%7Bfc.endpoint.host%7D:$%7Bfc.endpoint.port%7D/$%7Bfc.admin_cxf_nsmod.endpoint.path%7D]

/fc/admin is the path for the incoming request (defined by 
cxf:bean:fc-admin-service), not the one defined in the to-uri 
(${fc.admin_cxf_nsmod.endpoint.path}).

We tried to add the bridgeEndpoint property as in

<route id="cxf-admin-nsmap-route">
    <from uri="cxf:bean:fc-admin-service"/>
    <to 
uri="http://${fc.endpoint.host}:${fc.endpoint.port}/${fc.admin_cxf_nsmod.endpoint.path}?bridgeEndpoint=true"/>
</route>

This fails with

org.apache.commons.httpclient.URIException: Invalid authority


A different approach where we tried XSLT to transform the namespaces, use JAXB 
unmarshalling and create a MessageContentsList to convert the message into POJO 
format by hand which can then be sent into the routing decision route directly 
leads to difficulties with marshalling the response back: the namespace prefix 
for the type names in (as xsd in xsi:type="xsd:string") gets lost. On top, this 
approach seems still uglier an less maintainable than the first one I described.

What might be a working and clean, simple, maybe even elegant solution to this 
problem? It's simply mapping a message in one namespace to another!

Thank you,
Dirk


Reply via email to