我有一个WSDL文件,我正在使用XSOMParser来解析文件。但它给了一些例外。
我的代码是:
private void initXsom() throws IOException {
try {
SchemaImpl schema = (SchemaImpl) wsdlObject.getTypes()
.getExtensibilityElements().get(0);
Element el = schema.getElement();
InputStream is = prepareSchema(el);
XSOMParser parser = new XSOMParser();
// is needed to read element documentations which are inside
// annotations
parser.setAnnotationParser(new AnnotationFactory());
parser.parse(is);
String targetNamespace = wsdlObject.getTargetNamespace();
if (parser.getResult() == null)
throw new IOException(
"Could not initialize XML Schema");
schemaObject = parser.getResult().getSchema(targetNamespace);
addSchemaElements();
} catch (TransformerException | SAXException e) {
throw new IOException("Problem initializing XML Schema.", e);
}
}
它给了我例外:
Exception in thread "main" java.io.IOException: Problem initializing XML Schema.
at eu.impact_project.iif.ws.generic.WsdlDocument.initXsom(WsdlDocument.java:170)
at eu.impact_project.iif.ws.generic.WsdlDocument.<init>(WsdlDocument.java:105)
at eu.impact_project.iif.ws.generic.SoapService.<init>(SoapService.java:57)
at eu.impact_project.iif.ws.generic.SoapService.<init>(SoapService.java:47)
at soapUi.mainClass.main(mainClass.java:20)
Caused by: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Premature end of file.
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1239)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:649)
at org.xml.sax.helpers.XMLFilterImpl.parse(XMLFilterImpl.java:357)
at com.sun.xml.xsom.parser.JAXPParser.parse(JAXPParser.java:79)
at com.sun.xml.xsom.impl.parser.NGCCRuntimeEx.parseEntity(NGCCRuntimeEx.java:298)
at com.sun.xml.xsom.impl.parser.ParserContext.parse(ParserContext.java:87)
at com.sun.xml.xsom.parser.XSOMParser.parse(XSOMParser.java:147)
at com.sun.xml.xsom.parser.XSOMParser.parse(XSOMParser.java:102)
at eu.impact_project.iif.ws.generic.WsdlDocument.initXsom(WsdlDocument.java:158)
任何人都可以帮助我解决这个问题。 感谢