private Resource loadSchemas ( Definition definition ) throws WSDLException , IOException , TransformerException , TransformerFactoryConfigurationError { Types types = definition . getTypes ( ) ; Resource targetXsd = null ; Resource firstSchemaInWSDL = null ; if ( types != null ) { List < ? > schemaTypes = types . getExtensibilityElements ( ) ; for ( Object schemaObject : schemaTypes ) { if ( schemaObject instanceof SchemaImpl ) { SchemaImpl schema = ( SchemaImpl ) schemaObject ; inheritNamespaces ( schema , definition ) ; addImportedSchemas ( schema ) ; addIncludedSchemas ( schema ) ; if ( ! importedSchemas . contains ( getTargetNamespace ( schema ) ) ) { ByteArrayOutputStream bos = new ByteArrayOutputStream ( ) ; Source source = new DOMSource ( schema . getElement ( ) ) ; Result result = new StreamResult ( bos ) ; TransformerFactory . newInstance ( ) . newTransformer ( ) . transform ( source , result ) ; Resource schemaResource = new ByteArrayResource ( bos . toByteArray ( ) ) ; importedSchemas . add ( getTargetNamespace ( schema ) ) ; schemaResources . add ( schemaResource ) ; if ( definition . getTargetNamespace ( ) . equals ( getTargetNamespace ( schema ) ) && targetXsd == null ) { targetXsd = schemaResource ; } else if ( targetXsd == null && firstSchemaInWSDL == null ) { firstSchemaInWSDL = schemaResource ; } } } else { log . warn ( "Found unsupported schema type implementation " + schemaObject . getClass ( ) ) ; } } } for ( Object imports : definition . getImports ( ) . values ( ) ) { for ( Import wsdlImport : ( Vector < Import > ) imports ) { String schemaLocation ; URI locationURI = URI . create ( wsdlImport . getLocationURI ( ) ) ; if ( locationURI . isAbsolute ( ) ) { schemaLocation = wsdlImport . getLocationURI ( ) ; } else { schemaLocation = definition . getDocumentBaseURI ( ) . substring ( 0 , definition . getDocumentBaseURI ( ) . lastIndexOf ( ' ' ) + 1 ) + wsdlImport . getLocationURI ( ) ; } loadSchemas ( getWsdlDefinition ( new FileSystemResource ( schemaLocation ) ) ) ; } } if ( targetXsd == null ) { // Obviously no schema resource in WSDL did match the targetNamespace, just use the first schema resource found as main schema if ( firstSchemaInWSDL != null ) { targetXsd = firstSchemaInWSDL ; } else if ( ! CollectionUtils . isEmpty ( schemaResources ) ) { targetXsd = schemaResources . get ( 0 ) ; } } return targetXsd ; }
Loads nested schema type definitions from wsdl .