/** * Build a list of schema target name spaces which are element form qualified. * * @return All target name spaces for schemas defined in the WSDL which are element form qualified. */ private List<String> getElementFormQualifiedNamespaces() { List<String> namespaces = new ArrayList<String>(); List<ExtensibilityElement> schemas = getSchemas(); for ( ExtensibilityElement schema : schemas ) { Element schemaElement = ( (Schema) schema ).getElement(); if ( schemaElement.hasAttribute( WsdlUtils.ELEMENT_FORM_DEFAULT_ATTR ) ) { String v = schemaElement.getAttribute( WsdlUtils.ELEMENT_FORM_DEFAULT_ATTR ); if ( WsdlUtils.ELEMENT_FORM_QUALIFIED.equalsIgnoreCase( v ) ) { namespaces.add( schemaElement.getAttribute( WsdlUtils.TARGET_NAMESPACE_ATTR ) ); } } } return namespaces; }
/** * Get the schema with the specified target namespace. * * @param targetNamespace * target namespace of the schema to get. * @return null if not found. */ private Schema getSchema( String targetNamespace ) { if ( _types == null ) { return null; } List<ExtensibilityElement> schemas = WsdlUtils.findExtensibilityElements( _types, "schema" ); for ( ExtensibilityElement e : schemas ) { Element schemaRoot = ( (Schema) e ).getElement(); String tns = schemaRoot.getAttribute( "targetNamespace" ); if ( targetNamespace.equals( tns ) ) { return (Schema) e; } } return null; } }
/** * Create a new instance, parse the WSDL file for named complex types. * * @param wsdlTypes * Name space resolver. */ protected WsdlComplexTypes( WsdlTypes wsdlTypes ) { List<ExtensibilityElement> schemas = wsdlTypes.getSchemas(); for ( ExtensibilityElement schema : schemas ) { Element schemaRoot = ( (Schema) schema ).getElement(); List<Element> types = DomUtils.getChildElementsByName( schemaRoot, WsdlUtils.COMPLEX_TYPE_NAME ); for ( Element t : types ) { String schemaTypeName = t.getAttribute( WsdlUtils.NAME_ATTR ); _complexTypes.put( schemaTypeName, new ComplexType( t, wsdlTypes ) ); } } }
/** * Find a named <complexType> or <simpleType> in the types section of the WSDL. * * @param typeName * Name of the type to find. * @return null if type not found. */ protected Element findNamedType( QName typeName ) { Schema s = getSchema( typeName.getNamespaceURI() ); if ( s == null ) { return null; } Element schemaRoot = s.getElement(); // get all simple and complex types defined at the top-level. // List<Element> types = DomUtils.getChildElementsByName( schemaRoot, WsdlUtils.COMPLEX_TYPE_NAME ); types.addAll( DomUtils.getChildElementsByName( schemaRoot, WsdlUtils.SIMPLE_TYPE_NAME ) ); Element namedType = null; for ( Element t : types ) { String schemaTypeName = t.getAttribute( WsdlUtils.NAME_ATTR ); if ( typeName.getLocalPart().equals( schemaTypeName ) ) { namedType = t; break; } } return namedType; }
Element schemaRoot = s.getElement(); List<Element> elements = DomUtils.getChildElementsByName( schemaRoot, WsdlUtils.ELEMENT_NAME );
public void marshall(Class parentType, QName elementType, ExtensibilityElement extension, PrintWriter pw, Definition def, ExtensionRegistry extReg) throws WSDLException { Schema schema = (Schema)extension; pw.print(" "); DOM2Writer.serializeAsXML(schema.getElement(), def.getNamespaces(), pw); pw.println(); } }
/** * Reads target namespace from schema definition element. * @param schema * @return */ private String getTargetNamespace(Schema schema) { return schema.getElement().getAttribute("targetNamespace"); }
public void visit( ExtensibilityElement el, Object parent, WSDLTraversalContext ctx) { if (el instanceof Schema) searchForImport(((Schema) el).getElement()); }
/** * (non-Javadoc) * @see org.eclipse.wst.wsi.wsdl.traversal.WSDLVisitor#visit(Message, Object, WSDLTraversalContext) */ public void visit(ExtensibilityElement obj, Object parent, WSDLTraversalContext ctx) { if((obj != null) && (obj instanceof Schema)) { Schema el = (Schema) obj; try { processor.processAllSchema(el.getElement()); } catch (WSIException e) {} } }
/** * Converts a schema into a String. * @throws TransformerException If unable to transform the schema. */ public static String schemaToString(Schema schema) throws TransformerException { StringWriter writer = new StringWriter(); Transformer transformer = XMLSecureFactories.createDefault().getTransformerFactory().newTransformer(); transformer.transform(new DOMSource(schema.getElement()), new StreamResult(writer)); return writer.toString(); }
public void marshall(Class parentType, QName elementType, ExtensibilityElement extension, PrintWriter pw, Definition def, ExtensionRegistry extReg) throws WSDLException { Schema schema = (Schema)extension; pw.print(" "); DOM2Writer.serializeAsXML(schema.getElement(), def.getNamespaces(), pw); pw.println(); } }
@Override public void addMessages(Definition definition) throws WSDLException { Types types = definition.getTypes(); Assert.notNull(types, "No types element present in definition"); for (Iterator<?> iterator = types.getExtensibilityElements().iterator(); iterator.hasNext();) { ExtensibilityElement extensibilityElement = (ExtensibilityElement) iterator.next(); if (extensibilityElement instanceof Schema) { Schema schema = (Schema) extensibilityElement; if (schema.getElement() != null) { createMessages(definition, schema.getElement()); } } } if (definition.getMessages().isEmpty() && logger.isWarnEnabled()) { logger.warn("No messages were created, make sure the referenced schema(s) contain elements"); } }
public void addMessages(Definition definition) throws WSDLException { Types types = definition.getTypes(); Assert.notNull(types, "No types element present in definition"); for (Iterator<?> iterator = types.getExtensibilityElements().iterator(); iterator.hasNext();) { ExtensibilityElement extensibilityElement = (ExtensibilityElement) iterator.next(); if (extensibilityElement instanceof Schema) { Schema schema = (Schema) extensibilityElement; if (schema.getElement() != null) { createMessages(definition, schema.getElement()); } } } if (definition.getMessages().isEmpty() && logger.isWarnEnabled()) { logger.warn("No messages were created, make sure the referenced schema(s) contain elements"); } }
public void marshall(@SuppressWarnings("rawtypes") Class parentType, QName elementType, ExtensibilityElement extension, PrintWriter pw, Definition def, ExtensionRegistry extReg) throws WSDLException { try { writeXml(((Schema)extension).getElement(), pw); } catch (XMLStreamException e) { throw new WSDLException("", "Could not write schema.", e); } }
public void marshall(@SuppressWarnings("rawtypes") Class parentType, QName elementType, ExtensibilityElement extension, PrintWriter pw, Definition def, ExtensionRegistry extReg) throws WSDLException { try { writeXml(((Schema)extension).getElement(), pw); } catch (XMLStreamException e) { throw new WSDLException("", "Could not write schema.", e); } }
public void marshall(@SuppressWarnings("rawtypes") Class parentType, QName elementType, ExtensibilityElement extension, PrintWriter pw, Definition def, ExtensionRegistry extReg) throws WSDLException { try { writeXml(((Schema)extension).getElement(), pw); } catch (XMLStreamException e) { throw new WSDLException("", "Could not write schema.", e); } }
private static Source loadWsdlSource(String wsdl) throws Exception { Definition definition = loadDefinition(wsdl); if (definition.getTypes() != null) { for (Object o : definition.getTypes().getExtensibilityElements()) { if (o instanceof javax.wsdl.extensions.schema.Schema) { Element e = ((javax.wsdl.extensions.schema.Schema) o).getElement(); return new DOMSource(e); } } } return null; }
private static Boolean setMtomEnabled(Schema schema) { if (schema != null) { if (hasExpectedContentTypes(schema.getElement())) { return true; } for (List<SchemaImport> c : ((Map<String, List<SchemaImport>>)schema.getImports()).values()) { for (SchemaImport simport : c) { if (setMtomEnabled(simport.getReferencedSchema())) { return true; } } } } return false; }
private static Boolean setMtomEnabled(Schema schema) { if (schema != null) { if (hasExpectedContentTypes(schema.getElement())) { return true; } for (List<SchemaImport> c : ((Map<String, List<SchemaImport>>)schema.getImports()).values()) { for (SchemaImport simport : c) { if (setMtomEnabled(simport.getReferencedSchema())) { return true; } } } } return false; }
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; } public Document getDocument(Definition wsdlDef) throws WSDLException {