Hi there, Im trying to use axis create a web service which validates an xml document by using an xml schema. The java class works fine when used outside axis and I know that the xml doc is both well formed and valid. When I try to validate using a web service I get the stack trace below. I have also included the code for both the java class and the client. Any help with this would be much appreciated.
xception in thread "main" AxisFault faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException faultSubcode: faultString: java.lang.reflect.InvocationTargetException faultActor: faultNode: faultDetail: {http://xml.apache.org/axis/}stackTrace: AxisFault faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException faultSubcode: faultString: java.lang.reflect.InvocationTargetException faultActor: faultNode: faultDetail: java.lang.reflect.InvocationTargetException at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:260) at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:169) at org.apache.axis.encoding.DeserializationContextImpl.endElement(DeserializationContextImpl.java:1015) at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source) at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) at javax.xml.parsers.SAXParser.parse(SAXParser.java:375) at org.apache.axis.encoding.DeserializationContextImpl.parse(DeserializationContextImpl.java:242) at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:538) at org.apache.axis.Message.getSOAPEnvelope(Message.java:376) at org.apache.axis.client.Call.invokeEngine(Call.java:2583) at org.apache.axis.client.Call.invoke(Call.java:2553) at org.apache.axis.client.Call.invoke(Call.java:2248) at org.apache.axis.client.Call.invoke(Call.java:2171) at org.apache.axis.client.Call.invoke(Call.java:1691) at XML5ValidatorClient.main(XML5ValidatorClient.java:58) java.lang.reflect.InvocationTargetException at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:260) at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:169) at org.apache.axis.encoding.DeserializationContextImpl.endElement(DeserializationContextImpl.java:1015) at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source) at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) at javax.xml.parsers.SAXParser.parse(SAXParser.java:375) at org.apache.axis.encoding.DeserializationContextImpl.parse(DeserializationContextImpl.java:242) at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:538) at org.apache.axis.Message.getSOAPEnvelope(Message.java:376) at org.apache.axis.client.Call.invokeEngine(Call.java:2583) at org.apache.axis.client.Call.invoke(Call.java:2553) at org.apache.axis.client.Call.invoke(Call.java:2248) at org.apache.axis.client.Call.invoke(Call.java:2171) at org.apache.axis.client.Call.invoke(Call.java:1691) at XML5ValidatorClient.main(XML5ValidatorClient.java:58) Java Class: package WsTest.third; import javax.xml.*; import javax.xml.validation.*; import javax.xml.parsers.*; import org.w3c.dom.*; import org.xml.sax.*; import java.io.*; import javax.xml.transform.*; import javax.xml.transform.dom.*; import javax.xml.transform.stream.*; public class XML5Validator { public String validateSchema (String xsd, String xml) { if (xsd == null) return "Schema document not specified"; else if (xml == null) return "XML document not specified"; try { // parse an XML document into a DOM tree DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); Document document = parser.parse(new File(xml)); // create a SchemaFactory capable of understanding WXS schemas SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); // load a WXS schema, represented by a Schema instance Source schemaFile = new StreamSource(new File(xsd)); Schema schema = factory.newSchema(schemaFile); // create a Validator instance, which can be used to validate an instance document Validator validator = schema.newValidator(); DOMSource dom = new DOMSource(document); //validator.validate(new DOMSource(document)); validator.validate(dom); } catch (SAXException e) { //System.out.println("SAXException "+e.getMessage()); return "SAXException "+e.getMessage(); } catch (IOException ioe) { //System.out.println("IOException "+ioe.getMessage()); return "IOException "+ioe.getMessage(); } catch (ParserConfigurationException pce) { //System.out.println("ParserConfigurationException "+pce.getMessage()); return "ParserConfigurationException "+pce.getMessage(); } return "XML document is valid"; } } and the client public class XML5ValidatorClient { public static void main(String [] args) throws Exception { String host = "http://localhost:"; //String servicepath = "/axis/Quote.jws"; String servicepath = "/axis/servlet/AxisServlet"; Options options = new Options(args); int port = options.getPort(); String endpoint = host + port + servicepath; String method = null; args = options.getRemainingArgs(); String op1 = null; String op2 = null; op1 = "/home/michael/java/catalog.xsd"; op2 = "/home/michael/java/catalog.xml"; String retStr = null; Service service = new Service(); Call call = (Call) service.createCall(); call.setTargetEndpointAddress(new java.net.URL (endpoint)); call.addParameter("op1", XMLType.XSD_STRING, ParameterMode.IN); call.addParameter("op2", XMLType.XSD_STRING, ParameterMode.IN); call.setOperationName(new QName("XML5Validator", "validateSchema")); call.setReturnType(XMLType.XSD_STRING); retStr = (String) call.invoke(new Object [] {op1, op2}); System.out.println("Got result : " + retStr); } } ___________________________________________________________ Win a castle for NYE with your mates and Yahoo! Messenger http://uk.messenger.yahoo.com