我已经阅读过类似的主题和示例,但是我仍然有一些关于从WSDL获取复杂类型的WSDL模式内容的问题。
我正在使用WSDL4J,Castor和JDOM库。
org.exolab.castor.xml.schema.Schema castorSchema = null ;
if(theWSDL.getTypes() !=null && theWSDL.getTypes().getExtensibilityElements() !=null){
for (Object e : theWSDL.getTypes().getExtensibilityElements()) {
schema = (Schema)e;
}
}
if (schema != null) {
DOMBuilder domBuilder = new DOMBuilder();
Element jdomSchemaElement = domBuilder.build(schema.getElement());
XMLOutputter outputter = new XMLOutputter();
String xmlout = outputter.outputString(jdomSchemaElement.getDocument());
StringReader in2 = new StringReader(xmlout);
InputSource schemaSource = new InputSource(in2);
SchemaReader schemaReader;
try {
schemaReader = new SchemaReader(schemaSource);
castorSchema= schemaReader.read();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}此代码适用于某些WSDL文件,但对于某些WSDL文件,我收到了“castorSchema = schemaReader.read();”这行错误:
Exception in thread "main" java.lang.IllegalArgumentException: getComplexType: Namespace prefix not recognized 'tns:cEstado'
at org.exolab.castor.xml.schema.Schema.getComplexType(Schema.java:951)
at org.exolab.castor.xml.schema.TypeReference.resolveTypeReference(TypeReference.java:122)
at org.exolab.castor.xml.schema.TypeReference.getType(TypeReference.java:71)
at org.exolab.castor.xml.schema.ElementDecl.getType(ElementDecl.java:349)
at org.exolab.castor.xml.schema.ElementDecl.validate(ElementDecl.java:809)
at org.exolab.castor.xml.schema.Group.validate(Group.java:463)
at org.exolab.castor.xml.schema.ComplexType.validate(ComplexType.java:815)
at org.exolab.castor.xml.schema.Schema.validate(Schema.java:2206)
at org.exolab.castor.xml.schema.reader.SchemaReader.read(SchemaReader.java:261)
at network.WSNetwork.execute(WSNetwork.java:105)
at network.WSNetwork.main(WSNetwork.java:61)
有关模式中复杂类型的wsdl文件部分:
任何帮助将不胜感激..
谢谢