axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Davanum Srinivas <d...@yahoo.com>
Subject Re: WSDL Crimson vs. Xerces parser problem.
Date Fri, 30 Nov 2001 13:47:21 GMT
Thanks Edwin. Updated the error handling in Axis to report these problems...

-- dims

--- Edwin Goei <edwingo@sun.com> wrote:
> Davanum Srinivas wrote:
> > 
> > Edwin,
> > 
> > We ran into a problem with crimson. Here's a test case (test.java and FileGen.wsdl).
Can you
> > please take a look. I was able to recreate the problem with latest crimson from
cvs. Also see
> > below a stack trace.
> 
> I believe the problem is with the input WSDL file not being Namespace
> REC conformant.  There is a tag on line 97 '<http:binding verb="GET"'
> where the "http" prefix has not yet been defined.  I've modified the
> test program to install an ErrorHandler which prints out the error.
> 
> The way crimson works is that the DOM tree is built via SAX events and
> so produced the misleading stack trace.  I agree that it could be
> improved.  I am attaching a new version of the test program which
> installs an ErrorHandler.
> 
> -Edwin> import javax.xml.parsers.*;
> import org.xml.sax.*;
> import org.w3c.dom.*;
> import java.io.*;
> public class test2 {
> 	public static void main(String[] args) throws Exception {
> 		DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
> 		dbf.setNamespaceAware(true);
> 		DocumentBuilder db = dbf.newDocumentBuilder();
> 
>         // Set an ErrorHandler before parsing
>         OutputStreamWriter errorWriter =
>             new OutputStreamWriter(System.err, "UTF-8");
>         db.setErrorHandler(
>             new MyErrorHandler(new PrintWriter(errorWriter, true)));
> 
> 		Document doc = db.parse(new InputSource(args[0]));
> 	}
> 
>     // Error handler to report errors and warnings
>     private static class MyErrorHandler implements ErrorHandler {
>         /** Error handler output goes here */
>         private PrintWriter out;
> 
>         MyErrorHandler(PrintWriter out) {
>             this.out = out;
>         }
> 
>         /**
>          * Returns a string describing parse exception details
>          */
>         private String getParseExceptionInfo(SAXParseException spe) {
>             String systemId = spe.getSystemId();
>             if (systemId == null) {
>                 systemId = "null";
>             }
>             String info = "URI=" + systemId +
>                 " Line=" + spe.getLineNumber() +
>                 ": " + spe.getMessage();
>             return info;
>         }
> 
>         // The following methods are standard SAX ErrorHandler methods.
>         // See SAX documentation for more info.
> 
>         public void warning(SAXParseException spe) throws SAXException {
>             out.println("Warning: " + getParseExceptionInfo(spe));
>         }
>         
>         public void error(SAXParseException spe) throws SAXException {
>             String message = "Error: " + getParseExceptionInfo(spe);
>             throw new SAXException(message);
>         }
> 
>         public void fatalError(SAXParseException spe) throws SAXException {
>             String message = "Fatal Error: " + getParseExceptionInfo(spe);
>             throw new SAXException(message);
>         }
>     }
> }
> 


=====
Davanum Srinivas - http://jguru.com/dims/

__________________________________________________
Do You Yahoo!?
Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.
http://geocities.yahoo.com/ps/info1

Mime
View raw message