尝试访问在WSDL文件中导入的模式

时间:2014-03-20 12:45:23

标签: xml web-services wsdl schema

我正在尝试在我的WSDL文件中导入模式:

WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
            reader.setFeature ("javax.wsdl.verbose", false);
        reader.setFeature ("javax.wsdl.importDocuments",true);

        Definition def = reader.readWSDL("./wsdl/PrepaidAdmin.wsdl");
        System.out.println(def.getTypes());
                System.out.println("def.getExtensibilityElements().size()="+def.getExtensibilityElements().size());

这是Sysout的输出:

Sourcefile:/D:/WorkSpace/XSD Validation/wsdl/PrepaidAdmin.wsdl
Types:
SchemaExtensibilityElement ({http://www.w3.org/2001/XMLSchema}schema):
required=null
element=[xsd:schema: null]
SchemaExtensibilityElement ({http://www.w3.org/2001/XMLSchema}schema):
required=null
element=[xsd:schema: null]

我不明白为什么当WSDL导入两个模式时我得到null?Plz help

1 个答案:

答案 0 :(得分:0)

修正:

Map mp = new HashMap();

            for( Object o : def.getTypes().getExtensibilityElements()) {
                if( o instanceof javax.wsdl.extensions.schema.Schema ) {
                 //   org.w3c.dom.Element elt = ((javax.wsdl.extensions.schema.SchemaImport) o) //.getElement();
                    Schema sc = (javax.wsdl.extensions.schema.Schema) o;
                    mp.put(sc.getElement().getNamespaceURI(),sc);
                    mp.putAll(sc.getImports());
                    System.out.println(mp);
                                    //++i;
                    } 
            }