You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by rcohen16 <rc...@antennasoftware.com> on 2008/08/22 21:40:52 UTC
Creating STaX Interceptor
I'm trying to create an Interceptor that does some custom authentication by
reading credentials from the SOAP body. I want to avoid using SAAJ for
performance reasons since my payload may be rather large. I figured it makes
sense to use STaX to read only the content I need...The problem is, I can't
figure out how to use STaX in an Interceptor without disturbing other
Interceptors. I tried adding an Interceptor in the POST_PROTOCOL phase that
uses the XMLStreamReader from message.getContent(XMLStreamReader.class).
However, it I call next() on it, an Interceptor further down the chain
throws an error. Then I tried creating a new XMLStreamReader using the
InputStream from message.getContent(InputStream.class), but this stream is
already at EOF since a previous Interceptor already read it.
Any suggestions on how I can create or access an existing XMLStreamReader in
my Interceptor without impacting other Interceptors?
Thanks!
--
View this message in context: http://www.nabble.com/Creating-STaX-Interceptor-tp19114267p19114267.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: Creating STaX Interceptor
Posted by rcohen16 <rc...@antennasoftware.com>.
I took your advice and put my interceptor in the USER_LOGICAL phase and
accessed the JAXB objects directly. Worked like a charm, thanks!
dkulp wrote:
>
>
> This is probably not going to work very well or very easily without a
> bunch of
> code. Stax pretty much consumes things as it does it's work. Thus,
> once
> you read an event, if you don't save it in a way that you can replay it,
> this
> will cause problems.
>
> The only way I can really think this is going to work this way would be to
> convert the XmlStreamReader to an XmlEventReader. Read the event off,
> but
> record them in a List of events. Then write a custom XmlStreamReader
> that
> would first read from those saved events, and when they are consumed,
> revert
> back to reading from the original stream. Definitely complex.
>
> Another option: could you just use the parsed JAXB objects? Basically,
> put
> your interceptor in the USER_LOGICAL phase and get the contents list from
> the
> message and work with the data that was parsed into the objects.
>
> Dan
>
>
> On Friday 22 August 2008 3:40:52 pm rcohen16 wrote:
>> I'm trying to create an Interceptor that does some custom authentication
>> by
>> reading credentials from the SOAP body. I want to avoid using SAAJ for
>> performance reasons since my payload may be rather large. I figured it
>> makes sense to use STaX to read only the content I need...The problem is,
>> I
>> can't figure out how to use STaX in an Interceptor without disturbing
>> other
>> Interceptors. I tried adding an Interceptor in the POST_PROTOCOL phase
>> that
>> uses the XMLStreamReader from message.getContent(XMLStreamReader.class).
>> However, it I call next() on it, an Interceptor further down the chain
>> throws an error. Then I tried creating a new XMLStreamReader using the
>> InputStream from message.getContent(InputStream.class), but this stream
>> is
>> already at EOF since a previous Interceptor already read it.
>>
>> Any suggestions on how I can create or access an existing XMLStreamReader
>> in my Interceptor without impacting other Interceptors?
>>
>> Thanks!
>
>
>
> --
> Daniel Kulp
> dkulp@apache.org
> http://www.dankulp.com/blog
>
>
--
View this message in context: http://www.nabble.com/Creating-STaX-Interceptor-tp19114267p19145395.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: Creating STaX Interceptor
Posted by Daniel Kulp <dk...@apache.org>.
This is probably not going to work very well or very easily without a bunch of
code. Stax pretty much consumes things as it does it's work. Thus, once
you read an event, if you don't save it in a way that you can replay it, this
will cause problems.
The only way I can really think this is going to work this way would be to
convert the XmlStreamReader to an XmlEventReader. Read the event off, but
record them in a List of events. Then write a custom XmlStreamReader that
would first read from those saved events, and when they are consumed, revert
back to reading from the original stream. Definitely complex.
Another option: could you just use the parsed JAXB objects? Basically, put
your interceptor in the USER_LOGICAL phase and get the contents list from the
message and work with the data that was parsed into the objects.
Dan
On Friday 22 August 2008 3:40:52 pm rcohen16 wrote:
> I'm trying to create an Interceptor that does some custom authentication by
> reading credentials from the SOAP body. I want to avoid using SAAJ for
> performance reasons since my payload may be rather large. I figured it
> makes sense to use STaX to read only the content I need...The problem is, I
> can't figure out how to use STaX in an Interceptor without disturbing other
> Interceptors. I tried adding an Interceptor in the POST_PROTOCOL phase that
> uses the XMLStreamReader from message.getContent(XMLStreamReader.class).
> However, it I call next() on it, an Interceptor further down the chain
> throws an error. Then I tried creating a new XMLStreamReader using the
> InputStream from message.getContent(InputStream.class), but this stream is
> already at EOF since a previous Interceptor already read it.
>
> Any suggestions on how I can create or access an existing XMLStreamReader
> in my Interceptor without impacting other Interceptors?
>
> Thanks!
--
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog