File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes Axis2 ParseError Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Axis2 ParseError" Watch "Axis2 ParseError" New topic
Author

Axis2 ParseError

Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3700
    
    5

I'm connecting a Java Web Service client to a .NET-based web service using Axis2 (WSDL2Java generated code) and I'm getting a parse exception on reading the response:

Obviously, the server is trying to send a character that Axis2 believes should be escaped. Without re-writing Axis 2, though, is there a work around to handle this issue? In this situation, I cannot modify the server.

Alternatively, if the server is just 'doing bad things', I'd like to at least see the raw output message. Is there an obvious place in the generated code to output the raw response as text?


My Blog: Down Home Country Coding with Scott Selikoff
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

No, it's not an Axis restriction. It's an XML restriction -- that character can't appear in any well-formed XML document.

You say the server can't be changed, but if it's generating XML which isn't well-formed then it ought to be changed. That's a bug. Unless there's some encoding conflict happening. Or unless there's a bug in Java's implementation of the StAX parser. So yeah, looking at the actual XML document would be helpful before you start assigning blame.
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3700
    
    5

Paul Clapham wrote:No, it's not an Axis restriction. It's an XML restriction -- that character can't appear in any well-formed XML document.

You say the server can't be changed, but if it's generating XML which isn't well-formed then it ought to be changed. That's a bug. Unless there's some encoding conflict happening. Or unless there's a bug in Java's implementation of the StAX parser. So yeah, looking at the actual XML document would be helpful before you start assigning blame.


I agree whole-heartedly with 100% of everything you said, but that still leaves me stuck. I tried modifying the generated stub and called env.toString() to see the raw message but even that produces parse exceptions. My only recourse is to start recompiling some of the base classes for Axis/Axiom until I can at least output the raw message. I can't start a fuss unless I have access to the raw text.
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3700
    
    5

Well I got output but... lets just say I had to do a lot of 'bad things' including re-compile some rt.jar classes. But at least I can see whats coming back now.

The line to change was ultimately in com.ctc.wstx.sr.StreamScanner, around line 2321. One comment says:

This seems to imply that if the spec was set for XML 1.1, the exception would not occur. With that it mind, how do I change Axis2 to function using XML 1.1?

As a side note... can anyone find the page on the XML spec where it says low-number ASCII codes are invalid?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

If XML 1.1 is really being used, then I'd say that was an error in judgement by whoever set up the system. However if that's the case, what it means for you is that you're going to have to persuade your system to use an XML 1.1 compliant parser, if you can find such a thing. That probably doesn't involve doing anything to Axis itself, you'll just have to do the appropriate configuration so that choosing the StAX parser results in choosing the XML 1.1 compliant parser which you get from wherever.

It's section 2.2 of the XML Recommendation which tells you what characters are valid in XML.

Edit: did the XML document you saw actually say version ="1.1"?
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3700
    
    5

Paul Clapham wrote:Edit: did the XML document you saw actually say version ="1.1"?


No, but I'm sure that will be the first response.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

If you're getting an XML document with version="1.0" which contains the character reference "&#x5" then it's not a well-formed XML document. You aren't required to take extreme measures to process it.
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3700
    
    5

Paul Clapham wrote:You aren't required to take extreme measures to process it.


Aren't required by you perhaps. What I'm required to do to make my client work with an existing web service is a different story. Now that I have the raw output of the message, I'll contact the author and see if they can fix it on their side. There's no obligation on there part to fix it though.
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3700
    
    5

Result: The developer on the web service has since revised his interface. I was under the (possibly mistaken) impression other people were consuming the web service, but as it turns out I may be its first client. In other words, they haven't quite finished/tested it yet! Ha.

My only gripe with Axis2 is that it would have been nice to access the raw text in such a way that it didn't get parsed as XML in low-level readers. I had to go pretty deep to disable the checking that allowed me to see what the format was.

Thanks to Paul for his help!
 
 
subject: Axis2 ParseError
 
Similar Threads
java.io.IOException: Server returned HTTP response code: 503 for URL while using AXIS2 API
invoking a Axis2/Soap webservice
Axis2 service using JVM encoding charset instead of UTF-8
WebService Client call receives WstxUnexpectedCharException
Web Service security