cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Kulp <dk...@apache.org>
Subject Re: How to change the value of web service invocation attributes?
Date Mon, 27 Sep 2010 20:44:41 GMT
On Monday 27 September 2010 5:14:25 am Krzysztof Raszkowski wrote:
> Hi,
> we're dealing a problem with cxf interceptors. Our goal is to change the
> value of web service invocation attributes. For instance we have a method
> which is invoked with a string "in" and we want it changed to "out" before
> we get it in out application. We use a document literal wrapped style, so
> this text is a text content of the element "paramName", which is the child
> of the element "methodName" inside soapBody. We were trying to write
> interceptor but without any success.
> 
> We are able to change the expected value but it is only seen in our next
> interceptor (when we have two ones, one after another), but the method is
> then invoked with a null value. We did it by writing a class extending
> AbstractSoapInterceptor and handling a message implementing a SOAPMessage
> interface (we're getting a soap body, its nodes and then changing a text
> content). We expect, it should work during a pre protocol one, but we were
> trying this during many phases, with no success.

This should work.   What version of CXF are you using?  Can you produce a 
small testcase?   Maybe take our hello world and change the incoming text?

That said, using SAAJ is probably not the best idea from a performance 
standpoint.

> The second try was to create a class extending DepthXMLStreamReader class
> and overwrite some methods for processing the XML (actually getting the
> content, element name etc.). But it only works during a post stream phase
> in which there is no access to the whole XML content, only to some
> headers.

This is probably better from a performance standpoint.  The BEST place to put 
this is in POST_STREAM with and addAfter(StaxInInterceptor.class.getName()) 
set to put it immediately after the StaxInInterceptor.   Again, if it's not 
working, a testcase would be great.


The THIRD option that you didn't pursue is to not work at the XML level for 
this.   In an interceptor in the USER_LOGICAL phase, you can get the actual 
parameters (message.getContent(List.class)) and manipulate the already parsed  
objects. 


Hope that helps!
Dan



> We were looking for the solution but each example we found was showing how
> to read some values of the message (for example for logging) and it isn't a
> case for us. So we'd like to ask you if it's possible to change a soap body
> before web service invocation and if so, how to do it.
> 
> The other case, if modifying is possible, is it possible to change value of
> the method attribute before it's unmarshalled (but not by parsing input
> stream but using SOAPMessage interface (SoapMessage cxf implementation))?
> If not, what is the best way to do it?
> 
> Thanks in advance.

-- 
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog

Mime
View raw message