Java Code Examples for javax.wsdl.Definition#getTypes()

The following examples show how to use javax.wsdl.Definition#getTypes() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
private void parseWSDLTypes( XSOMParser schemaParser )
	throws IOException {
	Definition definition = getWSDLDefinition();
	if( definition != null ) {
		Types types = definition.getTypes();
		if( types != null ) {
			List< ExtensibilityElement > list = types.getExtensibilityElements();
			for( ExtensibilityElement element : list ) {
				if( element instanceof SchemaImpl ) {
					Element schemaElement = ((SchemaImpl) element).getElement();
					Map< String, String > namespaces = definition.getNamespaces();
					for( Entry< String, String > entry : namespaces.entrySet() ) {
						if( entry.getKey().equals( "xmlns" ) || entry.getKey().trim().isEmpty() ) {
							continue;
						}
						if( schemaElement.getAttribute( "xmlns:" + entry.getKey() ).isEmpty() ) {
							schemaElement.setAttribute( "xmlns:" + entry.getKey(), entry.getValue() );
						}
					}
					parseSchemaElement( definition, schemaElement, schemaParser );
				}
			}
		}
	}
}
 
Example 2
Source Project: cxf   File: SchemaWriterImpl.java    License: Apache License 2.0 6 votes vote down vote up
public Element getElement(Definition wsdlDef) throws WSDLException {
    Types types = wsdlDef.getTypes();
    if (types != null) {
        List<ExtensibilityElement> l = CastUtils.cast(types.getExtensibilityElements());
        if (l == null) {
            return null;
        }

        for (ExtensibilityElement e : l) {
            if (e instanceof Schema) {
                Schema sc = (Schema)e;
                return sc.getElement();
            }
        }
    }
    return null;
}
 
Example 3
Source Project: hop   File: WsdlTypes.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Create a new for WsdlTypes instance for the specified WSDL definition.
 *
 * @param wsdlDefinition The WSDL definition.
 */
@SuppressWarnings( "unchecked" )
protected WsdlTypes( Definition wsdlDefinition ) {

  _types = wsdlDefinition.getTypes();
  _targetNamespace = wsdlDefinition.getTargetNamespace();
  _prefixMappings = wsdlDefinition.getNamespaces();
  _elementFormQualifiedNamespaces = new HashSet<String>( getElementFormQualifiedNamespaces() );
  _namedComplexTypes = new WsdlComplexTypes( this );
}
 
Example 4
Source Project: tesb-studio-se   File: SchemaUtil.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public SchemaUtil(Definition wsdlDefinition) {
    if (null != wsdlDefinition.getTypes()) {
        init(wsdlDefinition.getTypes());
    }
    for (Collection<Import> wsdlImports : (Collection<Collection<Import>>) wsdlDefinition.getImports().values()) {
        for (Import wsdlImport : wsdlImports) {
            if (null != wsdlImport.getDefinition().getTypes()) {
                init(wsdlImport.getDefinition().getTypes());
            }
        }
    }
}
 
Example 5
Source Project: cxf   File: WSDLSchemaManager.java    License: Apache License 2.0 5 votes vote down vote up
public void addWSDLSchemaImport(Definition def, String tns, File file) throws Exception {
    // REVISIT, check if the wsdl schema already exists.
    Types types = def.getTypes();
    if (types == null) {
        types = def.createTypes();
        def.setTypes(types);
    }
    Schema wsdlSchema = (Schema)def.getExtensionRegistry()
        .createExtension(Types.class, new QName(Constants.URI_2001_SCHEMA_XSD, "schema"));

    addWSDLSchemaImport(wsdlSchema, tns, file);
    types.addExtensibilityElement(wsdlSchema);
}
 
Example 6
Source Project: cxf   File: WSDLCorbaWriterImpl.java    License: Apache License 2.0 5 votes vote down vote up
private void fixTypes(Definition wsdlDef) throws ParserConfigurationException {
    Types t = wsdlDef.getTypes();
    if (t == null) {
        return;
    }
    List<ExtensibilityElement> l = CastUtils.cast(t.getExtensibilityElements());
    if (l == null) {
        return;
    }

    for (ExtensibilityElement e : l) {
        if (e instanceof Schema) {
            Schema sc = (Schema)e;
            String pfx = wsdlDef.getPrefix(sc.getElementType().getNamespaceURI());
            if (StringUtils.isEmpty(pfx)) {
                pfx = "xsd";
                String ns = wsdlDef.getNamespace(pfx);
                int count = 1;
                while (!StringUtils.isEmpty(ns)) {
                    pfx = "xsd" + count++;
                    ns = wsdlDef.getNamespace(pfx);
                }
                wsdlDef.addNamespace(pfx, sc.getElementType().getNamespaceURI());
            }
            if (sc.getElement() == null) {
                fixSchema(sc, pfx);
            }
        }
    }
}
 
Example 7
Source Project: cxf   File: SchemaUtil.java    License: Apache License 2.0 5 votes vote down vote up
private void getSchemaList(Definition def) {
    Types typesElement = def.getTypes();
    if (typesElement != null) {
        Iterator<?> ite = typesElement.getExtensibilityElements().iterator();
        while (ite.hasNext()) {
            Object obj = ite.next();
            if (obj instanceof Schema) {
                Schema schema = (Schema)obj;
                addSchema(schema.getDocumentBaseURI(), schema);
            }
        }
    }
}
 
Example 8
Source Project: pentaho-kettle   File: WsdlTypes.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Create a new for WsdlTypes instance for the specified WSDL definition.
 *
 * @param wsdlDefinition
 *          The WSDL definition.
 */
@SuppressWarnings( "unchecked" )
protected WsdlTypes( Definition wsdlDefinition ) {

  _types = wsdlDefinition.getTypes();
  _targetNamespace = wsdlDefinition.getTargetNamespace();
  _prefixMappings = wsdlDefinition.getNamespaces();
  _elementFormQualifiedNamespaces = new HashSet<String>( getElementFormQualifiedNamespaces() );
  _namedComplexTypes = new WsdlComplexTypes( this );
}