You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Albert <al...@clearwire.com> on 2010/08/09 19:28:51 UTC
Problems with XMLSource
Hi,
I posted my message last friday and have got no response yet, except for a
mail saying the post has not yet been accepted by mailing list cuz i may not
be a user etc etc. So here's posting it again, please let me know if i'm
doing something wrong.
I'm using CXF 2.2.9
My JAX RS service method accepts XMLSource as the input type and i used
xpath expressions on it.
The first parse works fine. The second doesn't. I reversed the order and the
result is the same. I looked up your source, and it fails at this location
return xpath.evaluate(expression, getSource(), type); [XMLSource, #173]
with exception
</pre></p><p>root cause <pre>java.lang.IllegalArgumentException: Illegal
XPath expression '/usercredentials/username'
and the root cause as
</pre></p><p>root cause <pre>org.xml.sax.SAXParseException: Premature end of
file.
I looked up the internet, and from one of the posts, it could be because the
InputStream is already closed after the first parse.
http://www.danielschneller.com/2008/01/saxparseexception-1-1-premature-end-of.html
Please take a look.
Thank you.
--
View this message in context: http://cxf.547215.n5.nabble.com/Problems-with-XMLSource-tp2269114p2269114.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: Problems with XMLSource
Posted by Albert <al...@clearwire.com>.
Sergey,
Excellent solution! and what i call a real solution :) Worked like a charm.
FYI Sergey i did not receive your last reply.
Thanks much both of you.
--
View this message in context: http://cxf.547215.n5.nabble.com/Problems-with-XMLSource-tp2269114p2472190.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: Problems with XMLSource
Posted by Sergey Beryozkin <sb...@gmail.com>.
I did reply last week and suggested to use XMLSource.setBuffering(true)
Sergey
On Tue, Aug 10, 2010 at 2:15 AM, Daniel Kulp <dk...@apache.org> wrote:
>
> Any streaming XML parsing type thing will consume the InputStream. If you
> need to do multiple actions on it, you would need to somehow buffer the
> input
> into a form that can be read multiple times.
>
> The best way, in your case, would be to convert the XMLSource to a DOM and
> run
> the XPaths on that instead.
>
> Dan
>
>
> On Monday 09 August 2010 1:28:51 pm Albert wrote:
> > Hi,
> >
> > I posted my message last friday and have got no response yet, except for
> a
> > mail saying the post has not yet been accepted by mailing list cuz i may
> > not be a user etc etc. So here's posting it again, please let me know if
> > i'm doing something wrong.
> >
> >
> > I'm using CXF 2.2.9
> >
> > My JAX RS service method accepts XMLSource as the input type and i used
> > xpath expressions on it.
> >
> > The first parse works fine. The second doesn't. I reversed the order and
> > the result is the same. I looked up your source, and it fails at this
> > location
> >
> > return xpath.evaluate(expression, getSource(), type); [XMLSource, #173]
> >
> > with exception
> >
> > </pre></p><p>root cause <pre>java.lang.IllegalArgumentException: Illegal
> > XPath expression '/usercredentials/username'
> >
> > and the root cause as
> >
> > </pre></p><p>root cause <pre>org.xml.sax.SAXParseException: Premature end
> > of file.
> >
> > I looked up the internet, and from one of the posts, it could be because
> > the InputStream is already closed after the first parse.
> >
> >
> http://www.danielschneller.com/2008/01/saxparseexception-1-1-premature-end-
> > of.html
> >
> > Please take a look.
> >
> > Thank you.
>
> --
> Daniel Kulp
> dkulp@apache.org
> http://dankulp.com/blog
>
Re: Problems with XMLSource
Posted by Daniel Kulp <dk...@apache.org>.
Any streaming XML parsing type thing will consume the InputStream. If you
need to do multiple actions on it, you would need to somehow buffer the input
into a form that can be read multiple times.
The best way, in your case, would be to convert the XMLSource to a DOM and run
the XPaths on that instead.
Dan
On Monday 09 August 2010 1:28:51 pm Albert wrote:
> Hi,
>
> I posted my message last friday and have got no response yet, except for a
> mail saying the post has not yet been accepted by mailing list cuz i may
> not be a user etc etc. So here's posting it again, please let me know if
> i'm doing something wrong.
>
>
> I'm using CXF 2.2.9
>
> My JAX RS service method accepts XMLSource as the input type and i used
> xpath expressions on it.
>
> The first parse works fine. The second doesn't. I reversed the order and
> the result is the same. I looked up your source, and it fails at this
> location
>
> return xpath.evaluate(expression, getSource(), type); [XMLSource, #173]
>
> with exception
>
> </pre></p><p>root cause <pre>java.lang.IllegalArgumentException: Illegal
> XPath expression '/usercredentials/username'
>
> and the root cause as
>
> </pre></p><p>root cause <pre>org.xml.sax.SAXParseException: Premature end
> of file.
>
> I looked up the internet, and from one of the posts, it could be because
> the InputStream is already closed after the first parse.
>
> http://www.danielschneller.com/2008/01/saxparseexception-1-1-premature-end-
> of.html
>
> Please take a look.
>
> Thank you.
--
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog