Hi,

just in case someone has to solve the same problem, here is how I did:

Inbound:

Added an interceptor to the phase POST_STREAM, after StaxInInterceptor. This 
interceptor takes the
XMLStreamReader created by StaxInInterceptor and puts a wrapper around it. The 
wrapper translates
the namespaces and sets a threadlocal flag.

Outbound:

Added in interceptor to the phase PRE_MARSHAL. This interceptor takes the 
XMLStreamWriter created by
StaxOutInterceptor and puts another wrapper around it. This outbound wrapper 
evaluates the
threadlocal of the inbound wrapper and wraps the output accordingly.

However, by default, CXF will write the outgoing SOAP message directly to the 
ServletOutputStream
(see BareOutInterceptor.writeParts()). So I had to set the flag 
DISABLE_OUTPUTSTREAM_OPTIMIZATION in
the outbound interceptor to force CXF to use the (wrapped) XMLStreamWriter 
instead of the output stream.


This works quite nice. However, I am not quite sure about this output 
optimization. I could not find
any documentation about the drawbacks when writing to a XMLStreamWriter instead 
of the OutputStream.
Does someone have any hints about "DISABLE_OUTPUTSTREAM_OPTIMIZATION"?

Regards,
Martin

> Hi,
> 
> I have a web service (Soap 1.1, Document wrapped, JAXB) which uses the 
> namespace
> "http://something.old";. I would like to migrate this namespace to 
> "http://something.new";.
> 
> Unfortunately, there are quite some clients out there which use my service. 
> So I cannot just switch
> the namespace with a new release of my web service. Instead I would like to 
> have a "smooth" transition.
> 
> Some code would detect that a client is sending a document with the old 
> namespace. This code would
> rewrite the old namespace to the new namespace before/while the document is 
> being unmarshaled.
> Furthermore it would set a thread local flag that namespace translation was 
> used. Another piece of
> code in the output chain would evaluate this flag and would rewrite the new 
> namespace to the old
> namespace, if the flag is set.
> 
> This way, old clients would be able to send documents with the old namespace 
> and they would receive
> a response from the server with the old namespace.
> 
> Is this possible? Where do I have to start?
> 
> I already looked into StaxInInterceptor and StaxOutInterceptor. I think that 
> it would be possible to
> put a wrapper around XMLStreamReader and XMLStreamWriter, but this would be 
> rather cumbersome (and
> slow?). Is there an elegant solution to this problem?
> 
> Regards,
> Martin

Reply via email to