You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Oliver Wulff <ol...@sopera.com> on 2010/11/12 08:06:55 UTC

Fill element of type any without parsing the xml document in advance

Hi all



A web service provider has deployed an interceptor which should log the incoming message in a similar performant way as the logging interceptor but not into a file. Instead the incoming message is sent as part of a web service call with other monitoring related information. The message is passed as an any type.



I want to avoid that a DOM tree is created when filling the any type. I have to make a copy of the message because the message is sent in a seperated thread (scheduler) to not block processing of the incoming request.



I wanted to copy the stream into a string which can be read by the scheduler. But I haven't found a way to write the xml content of the cached string into the xml any.



Any hints are highly appreciated.



Thanks

Oli

AW: Fill element of type any without parsing the xml document in advance

Posted by Schneider Christian <Ch...@enbw.com>.
Hi Oli,
 
I think the big question is if the any type is good choice for an arbitrary message. For example the message could contain invalid xml that will make your whole webservice call invalid. So I propose to either base 64 encode the original message or send it as a MTOM attachment. In these cases you probably will not need to cope with a dom tree anyway.

The big disadvantage of course is that the resulting call is not nicely readable anymore.

Best Regards

Christian



Christian Schneider
Informationsverarbeitung 
Business Solutions
Handel und Dispatching

Tel : +49-(0)721-63-15482

EnBW Systeme Infrastruktur Support GmbH
Sitz der Gesellschaft: Karlsruhe
Handelsregister: Amtsgericht Mannheim ­ HRB 108550
Vorsitzender des Aufsichtsrats: Dr. Bernhard Beck
Geschäftsführer: Jochen Adenau, Hans-Günther Meier


-----Ursprüngliche Nachricht-----
Von: Oliver Wulff [mailto:oliver.wulff@sopera.com] 
Gesendet: Freitag, 12. November 2010 08:07
An: users@cxf.apache.org
Betreff: Fill element of type any without parsing the xml document in advance

Hi all



A web service provider has deployed an interceptor which should log the incoming message in a similar performant way as the logging interceptor but not into a file. Instead the incoming message is sent as part of a web service call with other monitoring related information. The message is passed as an any type.



I want to avoid that a DOM tree is created when filling the any type. I have to make a copy of the message because the message is sent in a seperated thread (scheduler) to not block processing of the incoming request.



I wanted to copy the stream into a string which can be read by the scheduler. But I haven't found a way to write the xml content of the cached string into the xml any.



Any hints are highly appreciated.



Thanks

Oli

AW: Fill element of type any without parsing the xml document in advance

Posted by Oliver Wulff <ol...@sopera.com>.
Hi Freeman

I don't know how I could fill the string (which contains the xml message) into an Any object without creating a DOM tree first? Maybe it's very easy but I haven't found much in the web how to deal with Any's. A hint would be great.

Message size is a very good point. I don't have a solution for that because I need a valid xml at the end. An idea is to parse the message till to the first child element of the soap body and put the value "truncated" in there.

Thanks
Oli


________________________________________
Von: Freeman Fang [freeman.fang@gmail.com]
Gesendet: Freitag, 12. November 2010 08:39
An: users@cxf.apache.org
Betreff: Re: Fill element of type any without parsing the xml document in advance

Hi,

I think you can still use CachedOutputStream  which is used in
LoggingInInterceptors(as you already mentioned).
Not sure why you don't wanna save it into a file, but actually you can
control to save it always in memory(although it's not a good idea for
very large message). By default only message size bigger then
64k(DEFAULT_THRESHOLD) will save as a temp file, you can change the
DEFAULT_THRESHOLD through java system property "org.apache.cxf.io.
CachedOutputStream.Threshold".

Also CachedOutputStream.toString() method can help you to write the
stream content into a String.

Freeman

On 2010-11-12, at 下午3:06, Oliver Wulff wrote:

> Hi all
>
>
>
> A web service provider has deployed an interceptor which should log
> the incoming message in a similar performant way as the logging
> interceptor but not into a file. Instead the incoming message is
> sent as part of a web service call with other monitoring related
> information. The message is passed as an any type.
>
>
>
> I want to avoid that a DOM tree is created when filling the any
> type. I have to make a copy of the message because the message is
> sent in a seperated thread (scheduler) to not block processing of
> the incoming request.
>
>
>
> I wanted to copy the stream into a string which can be read by the
> scheduler. But I haven't found a way to write the xml content of the
> cached string into the xml any.
>
>
>
> Any hints are highly appreciated.
>
>
>
> Thanks
>
> Oli


--
Freeman Fang

------------------------

FuseSource: http://fusesource.com
blog: http://freemanfang.blogspot.com
twitter: http://twitter.com/freemanfang
Apache Servicemix:http://servicemix.apache.org
Apache Cxf: http://cxf.apache.org
Apache Karaf: http://karaf.apache.org
Apache Felix: http://felix.apache.org

Re: Fill element of type any without parsing the xml document in advance

Posted by Freeman Fang <fr...@gmail.com>.
Hi,

I think you can still use CachedOutputStream  which is used in  
LoggingInInterceptors(as you already mentioned).
Not sure why you don't wanna save it into a file, but actually you can  
control to save it always in memory(although it's not a good idea for  
very large message). By default only message size bigger then  
64k(DEFAULT_THRESHOLD) will save as a temp file, you can change the  
DEFAULT_THRESHOLD through java system property "org.apache.cxf.io.  
CachedOutputStream.Threshold".

Also CachedOutputStream.toString() method can help you to write the  
stream content into a String.

Freeman

On 2010-11-12, at 下午3:06, Oliver Wulff wrote:

> Hi all
>
>
>
> A web service provider has deployed an interceptor which should log  
> the incoming message in a similar performant way as the logging  
> interceptor but not into a file. Instead the incoming message is  
> sent as part of a web service call with other monitoring related  
> information. The message is passed as an any type.
>
>
>
> I want to avoid that a DOM tree is created when filling the any  
> type. I have to make a copy of the message because the message is  
> sent in a seperated thread (scheduler) to not block processing of  
> the incoming request.
>
>
>
> I wanted to copy the stream into a string which can be read by the  
> scheduler. But I haven't found a way to write the xml content of the  
> cached string into the xml any.
>
>
>
> Any hints are highly appreciated.
>
>
>
> Thanks
>
> Oli


-- 
Freeman Fang

------------------------

FuseSource: http://fusesource.com
blog: http://freemanfang.blogspot.com
twitter: http://twitter.com/freemanfang
Apache Servicemix:http://servicemix.apache.org
Apache Cxf: http://cxf.apache.org
Apache Karaf: http://karaf.apache.org
Apache Felix: http://felix.apache.org