<schema>
element.
+ * This class is used to wrap schema elements. It holds the DOM Element to the <schema>
element.
*
* @see SchemaSerializer
* @see SchemaDeserializer
*
* @author Jeremy Hughes *
Name | - *Description | - *Default Value | - *
---|---|---|
If set to true, status messages will be displayed. | - *||
If set to true, imported WSDL documents will be - * retrieved and processed. | - *||
If set to true, the schema documents inlined and import directly - * or indrectly will be retrieved as javax.wsdl.extensions.schema.Schema - * objects and referred to in the Definition. This is the default (only) - * behaviour from JWSDL 1.2. Which is why the default for this feature is true. - * However, prior to JWSDL 1.2 the only behaviour was not to parse the schema - * files. Setting this feature to false will prevent the schemas being parsed. | - *||
Name | + *Description | + *Default Value | + *
If set to true, status messages will be displayed. | + *||
If set to true, imported WSDL documents will be retrieved and processed. | + *||
If set to true, the schema documents inlined and import directly or indrectly will be retrieved as javax.wsdl.extensions.schema.Schema objects and referred to in the Definition. This is the default (only) behaviour from JWSDL 1.2. Which is why the default for this feature is true. However, + * prior to JWSDL 1.2 the only behaviour was not to parse the schema files. Setting this feature to false will prevent the schemas being parsed. | + *
- * All feature names must be fully-qualified, Java package style. All - * names starting with javax.wsdl. are reserved for features defined - * by the JWSDL specification. It is recommended that implementation- - * specific features be fully-qualified to match the package name - * of that implementation. For example: com.abc.featureName + * All feature names must be fully-qualified, Java package style. All names starting with javax.wsdl. are reserved for features defined by the JWSDL specification. It is recommended that implementation- specific features be fully-qualified to match the package name of that implementation. For + * example: com.abc.featureName * - * @param name the name of the feature to be set. - * @param value the value to set the feature to. - * @throws IllegalArgumentException if the feature name is not recognized. + * @param name + * the name of the feature to be set. + * @param value + * the value to set the feature to. + * @throws IllegalArgumentException + * if the feature name is not recognized. * @see #getFeature(String) */ - public void setFeature(String name, boolean value) - throws IllegalArgumentException - { - if (name == null) - { + public void setFeature(String name, boolean value) throws IllegalArgumentException { + if (name == null) { throw new IllegalArgumentException("Feature name must not be null."); } - if (name.equals(Constants.FEATURE_VERBOSE)) - { + if (name.equals(Constants.FEATURE_VERBOSE)) { verbose = value; - } - else if (name.equals(Constants.FEATURE_IMPORT_DOCUMENTS)) - { + } else if (name.equals(Constants.FEATURE_IMPORT_DOCUMENTS)) { importDocuments = value; - } - else if (name.equals(Constants.FEATURE_PARSE_SCHEMA)) - { + } else if (name.equals(Constants.FEATURE_PARSE_SCHEMA)) { parseSchema = value; - } - else - { - throw new IllegalArgumentException("Feature name '" + name + - "' not recognized."); + } else { + throw new IllegalArgumentException("Feature name '" + name + "' not recognized."); } } /** * Gets the value of the specified feature. * - * @param name the name of the feature to get the value of. + * @param name + * the name of the feature to get the value of. * @return the value of the feature. - * @throws IllegalArgumentException if the feature name is not recognized. + * @throws IllegalArgumentException + * if the feature name is not recognized. * @see #setFeature(String, boolean) */ - public boolean getFeature(String name) throws IllegalArgumentException - { - if (name == null) - { + public boolean getFeature(String name) throws IllegalArgumentException { + if (name == null) { throw new IllegalArgumentException("Feature name must not be null."); } - if (name.equals(Constants.FEATURE_VERBOSE)) - { + if (name.equals(Constants.FEATURE_VERBOSE)) { return verbose; - } - else if (name.equals(Constants.FEATURE_IMPORT_DOCUMENTS)) - { + } else if (name.equals(Constants.FEATURE_IMPORT_DOCUMENTS)) { return importDocuments; - } - else - { - throw new IllegalArgumentException("Feature name '" + name + - "' not recognized."); + } else { + throw new IllegalArgumentException("Feature name '" + name + "' not recognized."); } } /** - * Set the extension registry to be used when reading - * WSDL documents into a WSDL definition. If an - * extension registry is set, that is the extension - * registry that will be set as the extensionRegistry - * property of the definitions resulting from invoking - * readWSDL(...). Default is null. + * Set the extension registry to be used when reading WSDL documents into a WSDL definition. If an extension registry is set, that is the extension registry that will be set as the extensionRegistry property of the definitions resulting from invoking readWSDL(...). Default is null. * - * @param extReg the extension registry to use for new - * definitions + * @param extReg + * the extension registry to use for new definitions */ - public void setExtensionRegistry(ExtensionRegistry extReg) - { + public void setExtensionRegistry(ExtensionRegistry extReg) { this.extReg = extReg; } /** - * Get the extension registry, if one was set. Default is - * null. + * Get the extension registry, if one was set. Default is null. */ - public ExtensionRegistry getExtensionRegistry() - { + public ExtensionRegistry getExtensionRegistry() { return extReg; } - + /** - * Get the WSDLFactory object cached in the reader, or use lazy - * instantiation if it is not cached yet. + * Get the WSDLFactory object cached in the reader, or use lazy instantiation if it is not cached yet. */ - protected WSDLFactory getWSDLFactory() throws WSDLException - { - if (factory == null) - { - factory = (factoryImplName != null) - ? WSDLFactory.newInstance(factoryImplName) - : WSDLFactory.newInstance(); + protected WSDLFactory getWSDLFactory() throws WSDLException { + if (factory == null) { + factory = (factoryImplName != null) ? WSDLFactory.newInstance(factoryImplName) : WSDLFactory.newInstance(); } return factory; } /** - * Set a different factory implementation to use for - * creating definitions when reading WSDL documents. - * As some WSDLReader implementations may only be - * capable of creating definitions using the same - * factory implementation from which the reader was - * obtained, this method is optional. Default is null. + * Set a different factory implementation to use for creating definitions when reading WSDL documents. As some WSDLReader implementations may only be capable of creating definitions using the same factory implementation from which the reader was obtained, this method is optional. Default is null. * - * @param factoryImplName the fully-qualified class name of the - * class which provides a concrete implementation of the abstract - * class WSDLFactory. - * @throws UnsupportedOperationException if this method - * is invoked on an implementation which does not - * support it. + * @param factoryImplName + * the fully-qualified class name of the class which provides a concrete implementation of the abstract class WSDLFactory. + * @throws UnsupportedOperationException + * if this method is invoked on an implementation which does not support it. */ - public void setFactoryImplName(String factoryImplName) - throws UnsupportedOperationException - { - //check to see if we really need to change the factory name and clear the cache - if((this.factoryImplName == null && factoryImplName != null) || - (this.factoryImplName != null && !this.factoryImplName.equals(factoryImplName))) - { - //the factory object is cached in the reader so set it - //to null if the factory impl name is reset. + public void setFactoryImplName(String factoryImplName) throws UnsupportedOperationException { + // check to see if we really need to change the factory name and clear the cache + if ((this.factoryImplName == null && factoryImplName != null) || (this.factoryImplName != null && !this.factoryImplName.equals(factoryImplName))) { + // the factory object is cached in the reader so set it + // to null if the factory impl name is reset. this.factory = null; - + this.factoryImplName = factoryImplName; - //if(verbose) System.out.println("WSDLFactory Impl Name set to : "+factoryImplName); } } /** * Get the factoryImplName, if one was set. Default is null. */ - public String getFactoryImplName() - { + public String getFactoryImplName() { return factoryImplName; } - protected Definition parseDefinitions(String documentBaseURI, - Element defEl, - Map importedDefs) - throws WSDLException - { + protected Definition parseDefinitions(String documentBaseURI, Element defEl, Map importedDefs) throws WSDLException { checkElementName(defEl, Constants.Q_ELEM_DEFINITIONS); - WSDLFactory factory = getWSDLFactory(); - Definition def = factory.newDefinition(); + Definition def = getWSDLFactory().newDefinition(); - if (extReg != null) - { + if (extReg != null) { def.setExtensionRegistry(extReg); } String name = DOMUtils.getAttribute(defEl, Constants.ATTR_NAME); - String targetNamespace = DOMUtils.getAttribute(defEl, - Constants.ATTR_TARGET_NAMESPACE); + String targetNamespace = DOMUtils.getAttribute(defEl, Constants.ATTR_TARGET_NAMESPACE); NamedNodeMap attrs = defEl.getAttributes(); - if (importedDefs == null) - { + if (importedDefs == null) { importedDefs = new Hashtable(); } - - if (documentBaseURI != null) - { + + if (documentBaseURI != null) { def.setDocumentBaseURI(documentBaseURI); importedDefs.put(documentBaseURI, def); } - if (name != null) - { + if (name != null) { def.setQName(new QName(targetNamespace, name)); } - if (targetNamespace != null) - { + if (targetNamespace != null) { def.setTargetNamespace(targetNamespace); } int size = attrs.getLength(); - for (int i = 0; i < size; i++) - { - Attr attr = (Attr)attrs.item(i); + for (int i = 0; i < size; i++) { + Attr attr = (Attr) attrs.item(i); String namespaceURI = attr.getNamespaceURI(); String localPart = attr.getLocalName(); String value = attr.getValue(); - if (namespaceURI != null && namespaceURI.equals(Constants.NS_URI_XMLNS)) - { - if (localPart != null && !localPart.equals(Constants.ATTR_XMLNS)) - { + if (namespaceURI != null && namespaceURI.equals(Constants.NS_URI_XMLNS)) { + if (localPart != null && !localPart.equals(Constants.ATTR_XMLNS)) { def.addNamespace(localPart, value); - } - else - { + } else { def.addNamespace(null, value); } } @@ -305,288 +229,185 @@ protected Definition parseDefinitions(String documentBaseURI, Element tempEl = DOMUtils.getFirstChildElement(defEl); - while (tempEl != null) - { - if (QNameUtils.matches(Constants.Q_ELEM_IMPORT, tempEl)) - { + while (tempEl != null) { + if (QNameUtils.matches(Constants.Q_ELEM_IMPORT, tempEl)) { def.addImport(parseImport(tempEl, def, importedDefs)); - } - else if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl)) - { + } else if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl)) { def.setDocumentationElement(tempEl); - } - else if (QNameUtils.matches(Constants.Q_ELEM_TYPES, tempEl)) - { + } else if (QNameUtils.matches(Constants.Q_ELEM_TYPES, tempEl)) { def.setTypes(parseTypes(tempEl, def)); - } - else if (QNameUtils.matches(Constants.Q_ELEM_MESSAGE, tempEl)) - { + } else if (QNameUtils.matches(Constants.Q_ELEM_MESSAGE, tempEl)) { def.addMessage(parseMessage(tempEl, def)); - } - else if (QNameUtils.matches(Constants.Q_ELEM_PORT_TYPE, tempEl)) - { + } else if (QNameUtils.matches(Constants.Q_ELEM_PORT_TYPE, tempEl)) { def.addPortType(parsePortType(tempEl, def)); - } - else if (QNameUtils.matches(Constants.Q_ELEM_BINDING, tempEl)) - { + } else if (QNameUtils.matches(Constants.Q_ELEM_BINDING, tempEl)) { def.addBinding(parseBinding(tempEl, def)); - } - else if (QNameUtils.matches(Constants.Q_ELEM_SERVICE, tempEl)) - { + } else if (QNameUtils.matches(Constants.Q_ELEM_SERVICE, tempEl)) { def.addService(parseService(tempEl, def)); - } - else - { - def.addExtensibilityElement( - parseExtensibilityElement(Definition.class, tempEl, def)); + } else { + def.addExtensibilityElement(parseExtensibilityElement(Definition.class, tempEl, def)); } tempEl = DOMUtils.getNextSiblingElement(tempEl); } parseExtensibilityAttributes(defEl, Definition.class, def, def); - + return def; } - protected Import parseImport(Element importEl, - Definition def, - Map importedDefs) - throws WSDLException - { + protected Import parseImport(Element importEl, Definition def, Map importedDefs) throws WSDLException { Import importDef = def.createImport(); - try - { - String namespaceURI = DOMUtils.getAttribute(importEl, - Constants.ATTR_NAMESPACE); - String locationURI = DOMUtils.getAttribute(importEl, - Constants.ATTR_LOCATION); + try { + String namespaceURI = DOMUtils.getAttribute(importEl, Constants.ATTR_NAMESPACE); + String locationURI = DOMUtils.getAttribute(importEl, Constants.ATTR_LOCATION); String contextURI = null; - if (namespaceURI != null) - { + if (namespaceURI != null) { importDef.setNamespaceURI(namespaceURI); } - if (locationURI != null) - { + if (locationURI != null) { importDef.setLocationURI(locationURI); - if (importDocuments) - { - try - { + if (importDocuments) { + try { contextURI = def.getDocumentBaseURI(); Definition importedDef = null; InputStream inputStream = null; InputSource inputSource = null; URL url = null; - if (loc != null) - { + if (loc != null) { inputSource = loc.getImportInputSource(contextURI, locationURI); /* - We now have available the latest import URI. This might - differ from the locationURI so check the importedDefs for it - since it is this that we pass as the documentBaseURI later. - */ + * We now have available the latest import URI. This might differ from the locationURI so check the importedDefs for it since it is this that we pass as the documentBaseURI later. + */ String liu = loc.getLatestImportURI(); - importedDef = (Definition)importedDefs.get(liu); - + importedDef = (Definition) importedDefs.get(liu); + inputSource.setSystemId(liu); - } - else - { - URL contextURL = (contextURI != null) - ? StringUtils.getURL(null, contextURI) - : null; + } else { + URL contextURL = (contextURI != null) ? StringUtils.getURL(null, contextURI) : null; url = StringUtils.getURL(contextURL, locationURI); - importedDef = (Definition)importedDefs.get(url.toString()); + importedDef = (Definition) importedDefs.get(url.toString()); - if (importedDef == null) - { + if (importedDef == null) { inputStream = StringUtils.getContentAsInputStream(url); - if (inputStream != null) - { + if (inputStream != null) { inputSource = new InputSource(inputStream); inputSource.setSystemId(url.toString()); } } } - if (importedDef == null) - { - if (inputSource == null) - { - throw new WSDLException(WSDLException.OTHER_ERROR, - "Unable to locate imported document " + - "at '" + locationURI + "'" + - (contextURI == null - ? "." - : ", relative to '" + contextURI + - "'.")); + if (importedDef == null) { + if (inputSource == null) { + throw new WSDLException(WSDLException.OTHER_ERROR, "Unable to locate imported document " + "at '" + locationURI + "'" + (contextURI == null ? "." : ", relative to '" + contextURI + "'.")); } Document doc = getDocument(inputSource, inputSource.getSystemId()); - if (inputStream != null) - { + if (inputStream != null) { inputStream.close(); } Element documentElement = doc.getDocumentElement(); /* - Check if it's a wsdl document. - If it's not, don't retrieve and process it. - This should later be extended to allow other types of - documents to be retrieved and processed, such as schema - documents (".xsd"), etc... - */ - if (QNameUtils.matches(Constants.Q_ELEM_DEFINITIONS, - documentElement)) - { - if (verbose) - { - System.out.println("Retrieving document at '" + locationURI + - "'" + - (contextURI == null - ? "." - : ", relative to '" + contextURI + "'.")); + * Check if it's a wsdl document. If it's not, don't retrieve and process it. This should later be extended to allow other types of documents to be retrieved and processed, such as schema documents (".xsd"), etc... + */ + if (QNameUtils.matches(Constants.Q_ELEM_DEFINITIONS, documentElement)) { + if (verbose) { + System.out.println("Retrieving document at '" + locationURI + "'" + (contextURI == null ? "." : ", relative to '" + contextURI + "'.")); } - String urlString = - (loc != null) - ? loc.getLatestImportURI() - : (url != null) - ? url.toString() - : locationURI; + String urlString = (loc != null) ? loc.getLatestImportURI() : (url != null) ? url.toString() : locationURI; - importedDef = readWSDL(urlString, - documentElement, - importedDefs); - } - else - { + importedDef = readWSDL(urlString, documentElement, importedDefs); + } else { QName docElementQName = QNameUtils.newQName(documentElement); - if (SchemaConstants.XSD_QNAME_LIST.contains(docElementQName)) - { - if (verbose) - { - System.out.println("Retrieving schema wsdl:imported from '" + locationURI + - "'" + - (contextURI == null - ? "." - : ", relative to '" + contextURI + "'.")); + if (SchemaConstants.XSD_QNAME_LIST.contains(docElementQName)) { + if (verbose) { + System.out.println("Retrieving schema wsdl:imported from '" + locationURI + "'" + (contextURI == null ? "." : ", relative to '" + contextURI + "'.")); } - + WSDLFactory factory = getWSDLFactory(); importedDef = factory.newDefinition(); - if (extReg != null) - { + if (extReg != null) { importedDef.setExtensionRegistry(extReg); } - String urlString = - (loc != null) - ? loc.getLatestImportURI() - : (url != null) - ? url.toString() - : locationURI; + String urlString = (loc != null) ? loc.getLatestImportURI() : (url != null) ? url.toString() : locationURI; importedDef.setDocumentBaseURI(urlString); Types types = importedDef.createTypes(); - types.addExtensibilityElement( - parseSchema(Types.class, documentElement, importedDef)); + types.addExtensibilityElement(parseSchema(Types.class, documentElement, importedDef)); importedDef.setTypes(types); } } } - if (importedDef != null) - { + if (importedDef != null) { importDef.setDefinition(importedDef); } - } - catch (WSDLException e) - { - throw e; - } - catch (RuntimeException e) - { + } catch (WSDLException e) { throw e; + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new WSDLException(WSDLException.OTHER_ERROR, "Unable to resolve imported document at '" + locationURI + (contextURI == null ? "'." : "', relative to '" + contextURI + "'"), e); } - catch (Exception e) - { - throw new WSDLException(WSDLException.OTHER_ERROR, - "Unable to resolve imported document at '" + - locationURI + - (contextURI == null - ? "'." : "', relative to '" + contextURI + "'") - , e); - } - } //end importDocs - } //end locationURI - - } - catch (WSDLException e) - { - if (e.getLocation() == null) - { + } // end importDocs + } // end locationURI + + } catch (WSDLException e) { + if (e.getLocation() == null) { e.setLocation(XPathUtils.getXPathExprFromNode(importEl)); - } - else - { - //If definitions are being parsed recursively for nested imports - //the exception location must be built up recursively too so - //prepend this element's xpath to exception location. + } else { + // If definitions are being parsed recursively for nested imports + // the exception location must be built up recursively too so + // prepend this element's xpath to exception location. String loc = XPathUtils.getXPathExprFromNode(importEl) + e.getLocation(); e.setLocation(loc); } - throw e; - } + throw e; + } - //register any NS decls with the Definition + // register any NS decls with the Definition NamedNodeMap attrs = importEl.getAttributes(); registerNSDeclarations(attrs, def); Element tempEl = DOMUtils.getFirstChildElement(importEl); - while (tempEl != null) - { - if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl)) - { + while (tempEl != null) { + if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl)) { importDef.setDocumentationElement(tempEl); - } - else - { - importDef.addExtensibilityElement( - parseExtensibilityElement(Import.class, tempEl, def)); + } else { + importDef.addExtensibilityElement(parseExtensibilityElement(Import.class, tempEl, def)); } tempEl = DOMUtils.getNextSiblingElement(tempEl); - } + } parseExtensibilityAttributes(importEl, Import.class, importDef, def); - - return importDef; - + + return importDef; + } - protected Types parseTypes(Element typesEl, Definition def) - throws WSDLException - { - //register any NS decls with the Definition + protected Types parseTypes(Element typesEl, Definition def) throws WSDLException { + // register any NS decls with the Definition NamedNodeMap attrs = typesEl.getAttributes(); registerNSDeclarations(attrs, def); @@ -594,369 +415,261 @@ protected Types parseTypes(Element typesEl, Definition def) Element tempEl = DOMUtils.getFirstChildElement(typesEl); QName tempElType; - while (tempEl != null) - { + while (tempEl != null) { tempElType = QNameUtils.newQName(tempEl); - - if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl)) - { + + if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl)) { types.setDocumentationElement(tempEl); - } - else if ((SchemaConstants.XSD_QNAME_LIST).contains(tempElType)) - { - if (parseSchema) - { - //the element qname indicates it is a schema. - types.addExtensibilityElement( - parseSchema(Types.class, tempEl, def)); + } else if ((SchemaConstants.XSD_QNAME_LIST).contains(tempElType)) { + if (parseSchema) { + // the element qname indicates it is a schema. + types.addExtensibilityElement(parseSchema(Types.class, tempEl, def)); + } else { + types.addExtensibilityElement(parseExtensibilityElementAsDefaultExtensiblityElement(Types.class, tempEl, def)); } - else - { - types.addExtensibilityElement(parseExtensibilityElementAsDefaultExtensiblityElement(Types.class, tempEl, def)); - } - } - else - { - types.addExtensibilityElement( - parseExtensibilityElement(Types.class, tempEl, def)); + } else { + types.addExtensibilityElement(parseExtensibilityElement(Types.class, tempEl, def)); } tempEl = DOMUtils.getNextSiblingElement(tempEl); } parseExtensibilityAttributes(typesEl, Types.class, types, def); - + return types; } - - protected ExtensibilityElement parseSchema( Class parentType, - Element el, - Definition def) - throws WSDLException - { + + protected ExtensibilityElement parseSchema(Class parentType, Element el, Definition def) throws WSDLException { QName elementType = null; ExtensionRegistry extReg = null; - try - { - extReg = def.getExtensionRegistry(); - - if (extReg == null) - { - throw new WSDLException(WSDLException.CONFIGURATION_ERROR, - "No ExtensionRegistry set for this " + - "Definition, so unable to deserialize " + - "a '" + elementType + "' element in the " + - "context of a '" + parentType.getName() + - "'."); - } - - return parseSchema(parentType, el, def, extReg); - } - catch (WSDLException e) - { - if (e.getLocation() == null) - { + try { + extReg = def.getExtensionRegistry(); + + if (extReg == null) { + throw new WSDLException(WSDLException.CONFIGURATION_ERROR, "No ExtensionRegistry set for this " + "Definition, so unable to deserialize " + "a '" + elementType + "' element in the " + "context of a '" + parentType.getName() + "'."); + } + + return parseSchema(parentType, el, def, extReg); + } catch (WSDLException e) { + if (e.getLocation() == null) { e.setLocation(XPathUtils.getXPathExprFromNode(el)); } - - throw e; - } + + throw e; + } } - - - protected ExtensibilityElement parseSchema( Class parentType, - Element el, - Definition def, - ExtensionRegistry extReg) - throws WSDLException - { + + protected ExtensibilityElement parseSchema(Class parentType, Element el, Definition def, ExtensionRegistry extReg) throws WSDLException { /* - * This method returns ExtensibilityElement rather than Schema because we - * do not insist that a suitable XSD schema deserializer is registered. - * PopulatedExtensionRegistry registers SchemaDeserializer by default, but - * if the user chooses not to register a suitable deserializer then the - * UnknownDeserializer will be used, returning an UnknownExtensibilityElement. + * This method returns ExtensibilityElement rather than Schema because we do not insist that a suitable XSD schema deserializer is registered. PopulatedExtensionRegistry registers SchemaDeserializer by default, but if the user chooses not to register a suitable deserializer then the + * UnknownDeserializer will be used, returning an UnknownExtensibilityElement. */ - - Schema schema = null; + + Schema schema = null; SchemaReference schemaRef = null; - try - { + try { QName elementType = QNameUtils.newQName(el); - - ExtensionDeserializer exDS = - extReg.queryDeserializer(parentType, elementType); - - //Now unmarshall the DOM element. - ExtensibilityElement ee = - exDS.unmarshall(parentType, elementType, el, def, extReg); - - if (ee instanceof Schema) - { - schema = (Schema) ee; - } - else - { - //Unknown extensibility element, so don't do any more schema parsing on it. - return ee; - } - - - //Keep track of parsed schemas to avoid duplicating Schema objects - //through duplicate or circular references (eg: A imports B imports A). - if (schema.getDocumentBaseURI() != null) - { - this.allSchemas.put(schema.getDocumentBaseURI(), schema); - } - - //At this point, any SchemaReference objects held by the schema will not - //yet point to their referenced schemas, so we must now retrieve these - //schemas and set the schema references. - - //First, combine the schema references for imports, includes and redefines - //into a single list - - ArrayList allSchemaRefs = new ArrayList(); - - Collection ic = schema.getImports().values(); - Iterator importsIterator = ic.iterator(); - while(importsIterator.hasNext()) - { - allSchemaRefs.addAll( (Collection) importsIterator.next() ); - } - - allSchemaRefs.addAll(schema.getIncludes()); - allSchemaRefs.addAll(schema.getRedefines()); - - //Then, retrieve the schema referred to by each schema reference. If the - //schema has been read in previously, use the existing schema object. - //Otherwise unmarshall the DOM element into a new schema object. - - ListIterator schemaRefIterator = allSchemaRefs.listIterator(); - - while(schemaRefIterator.hasNext()) - { - try - { - schemaRef = (SchemaReference) schemaRefIterator.next(); - - if (schemaRef.getSchemaLocationURI() == null) - { - //cannot get the referenced schema, so ignore this schema reference - continue; - } - - if (verbose) - { - System.out.println("Retrieving schema at '" + - schemaRef.getSchemaLocationURI() + - (schema.getDocumentBaseURI() == null - ? "'." - : "', relative to '" + - schema.getDocumentBaseURI() + "'.")); - } - - - InputStream inputStream = null; - InputSource inputSource = null; - - //This is the child schema referred to by the schemaReference - Schema referencedSchema = null; - - //This is the child schema's location obtained from the WSDLLocator or the URL - String location = null; - - if (loc != null) - { - //Try to get the referenced schema using the wsdl locator - inputSource = loc.getImportInputSource( - schema.getDocumentBaseURI(), schemaRef.getSchemaLocationURI()); - - if (inputSource == null) - { - throw new WSDLException(WSDLException.OTHER_ERROR, - "Unable to locate with a locator " - + "the schema referenced at '" - + schemaRef.getSchemaLocationURI() - + "' relative to document base '" - + schema.getDocumentBaseURI() + "'"); - } - location = loc.getLatestImportURI(); - - //if a schema from this location has been read previously, use it. - referencedSchema = (Schema) this.allSchemas.get(location); - } - else - { - // We don't have a wsdl locator, so try to retrieve the schema by its URL - String contextURI = schema.getDocumentBaseURI(); - URL contextURL = (contextURI != null) ? StringUtils.getURL(null, contextURI) : null; - URL url = StringUtils.getURL(contextURL, schemaRef.getSchemaLocationURI()); - location = url.toExternalForm(); - - //if a schema from this location has been retrieved previously, use it. - referencedSchema = (Schema) this.allSchemas.get(location); - - if (referencedSchema == null) - { - // We haven't read this schema in before so do it now + + ExtensionDeserializer exDS = extReg.queryDeserializer(parentType, elementType); + + // Now unmarshall the DOM element. + ExtensibilityElement ee = exDS.unmarshall(parentType, elementType, el, def, extReg); + + if (ee instanceof Schema) { + schema = (Schema) ee; + } else { + // Unknown extensibility element, so don't do any more schema parsing on it. + return ee; + } + + // Keep track of parsed schemas to avoid duplicating Schema objects + // through duplicate or circular references (eg: A imports B imports A). + if (schema.getDocumentBaseURI() != null) { + this.allSchemas.put(schema.getDocumentBaseURI(), schema); + } + + // At this point, any SchemaReference objects held by the schema will not + // yet point to their referenced schemas, so we must now retrieve these + // schemas and set the schema references. + + // First, combine the schema references for imports, includes and redefines + // into a single list + + ArrayList allSchemaRefs = new ArrayList(); + + Collection ic = schema.getImports().values(); + Iterator importsIterator = ic.iterator(); + while (importsIterator.hasNext()) { + allSchemaRefs.addAll((Collection) importsIterator.next()); + } + + allSchemaRefs.addAll(schema.getIncludes()); + allSchemaRefs.addAll(schema.getRedefines()); + + // Then, retrieve the schema referred to by each schema reference. If the + // schema has been read in previously, use the existing schema object. + // Otherwise unmarshall the DOM element into a new schema object. + + ListIterator schemaRefIterator = allSchemaRefs.listIterator(); + + while (schemaRefIterator.hasNext()) { + try { + schemaRef = (SchemaReference) schemaRefIterator.next(); + + if (schemaRef.getSchemaLocationURI() == null) { + // cannot get the referenced schema, so ignore this schema reference + continue; + } + + if (verbose) { + System.out.println("Retrieving schema at '" + schemaRef.getSchemaLocationURI() + (schema.getDocumentBaseURI() == null ? "'." : "', relative to '" + schema.getDocumentBaseURI() + "'.")); + } + + InputStream inputStream = null; + InputSource inputSource = null; + + // This is the child schema referred to by the schemaReference + Schema referencedSchema = null; + + // This is the child schema's location obtained from the WSDLLocator or the URL + String location = null; + + if (loc != null) { + // Try to get the referenced schema using the wsdl locator + inputSource = loc.getImportInputSource(schema.getDocumentBaseURI(), schemaRef.getSchemaLocationURI()); + + if (inputSource == null) { + throw new WSDLException(WSDLException.OTHER_ERROR, "Unable to locate with a locator " + "the schema referenced at '" + schemaRef.getSchemaLocationURI() + "' relative to document base '" + schema.getDocumentBaseURI() + "'"); + } + location = loc.getLatestImportURI(); + + // if a schema from this location has been read previously, use it. + referencedSchema = (Schema) this.allSchemas.get(location); + } else { + // We don't have a wsdl locator, so try to retrieve the schema by its URL + String contextURI = schema.getDocumentBaseURI(); + URL contextURL = (contextURI != null) ? StringUtils.getURL(null, contextURI) : null; + URL url = StringUtils.getURL(contextURL, schemaRef.getSchemaLocationURI()); + location = url.toExternalForm(); + + // if a schema from this location has been retrieved previously, use it. + referencedSchema = (Schema) this.allSchemas.get(location); + + if (referencedSchema == null) { + // We haven't read this schema in before so do it now inputStream = StringUtils.getContentAsInputStream(url); - if (inputStream != null) - { - inputSource = new InputSource(inputStream); - } - - if (inputSource == null) - { - throw new WSDLException(WSDLException.OTHER_ERROR, - "Unable to locate with a url " - + "the document referenced at '" - + schemaRef.getSchemaLocationURI() - + "'" - + (contextURI == null ? "." : ", relative to '" - + contextURI + "'.")); + if (inputStream != null) { + inputSource = new InputSource(inputStream); } - } - - } //end if loc - - // If we have not previously read the schema, get its DOM element now. - if (referencedSchema == null) - { - inputSource.setSystemId(location); - Document doc = getDocument(inputSource, location); - - if (inputStream != null) - { - inputStream.close(); - } - - Element documentElement = doc.getDocumentElement(); - - // If it's a schema doc process it, otherwise the schema reference remains null - - QName docElementQName = QNameUtils.newQName(documentElement); - - if (SchemaConstants.XSD_QNAME_LIST.contains(docElementQName)) - { - //We now need to call parseSchema recursively to parse the referenced - //schema. The document base URI of the referenced schema will be set to - //the document base URI of the current schema plus the schemaLocation in - //the schemaRef. We cannot explicitly pass in a new document base URI - //to the schema deserializer, so instead we will create a dummy - //Definition and set its documentBaseURI to the new document base URI. - //We can leave the other definition fields empty because we know - //that the SchemaDeserializer.unmarshall method uses the definition - //parameter only to get its documentBaseURI. If the unmarshall method - //implementation changes (ie: its use of definition changes) we may need - //to rethink this approach. - + + if (inputSource == null) { + throw new WSDLException(WSDLException.OTHER_ERROR, "Unable to locate with a url " + "the document referenced at '" + schemaRef.getSchemaLocationURI() + "'" + (contextURI == null ? "." : ", relative to '" + contextURI + "'.")); + } + } + + } // end if loc + + // If we have not previously read the schema, get its DOM element now. + if (referencedSchema == null) { + inputSource.setSystemId(location); + Document doc = getDocument(inputSource, location); + + if (inputStream != null) { + inputStream.close(); + } + + Element documentElement = doc.getDocumentElement(); + + // If it's a schema doc process it, otherwise the schema reference remains null + + QName docElementQName = QNameUtils.newQName(documentElement); + + if (SchemaConstants.XSD_QNAME_LIST.contains(docElementQName)) { + // We now need to call parseSchema recursively to parse the referenced + // schema. The document base URI of the referenced schema will be set to + // the document base URI of the current schema plus the schemaLocation in + // the schemaRef. We cannot explicitly pass in a new document base URI + // to the schema deserializer, so instead we will create a dummy + // Definition and set its documentBaseURI to the new document base URI. + // We can leave the other definition fields empty because we know + // that the SchemaDeserializer.unmarshall method uses the definition + // parameter only to get its documentBaseURI. If the unmarshall method + // implementation changes (ie: its use of definition changes) we may need + // to rethink this approach. + WSDLFactory factory = getWSDLFactory(); Definition dummyDef = factory.newDefinition(); - + dummyDef.setDocumentBaseURI(location); - //By this point, we know we have a SchemaDeserializer registered - //so we can safely cast the ExtensibilityElement to a Schema. - referencedSchema = (Schema) parseSchema( parentType, - documentElement, - dummyDef, - extReg); - } - - } //end if referencedSchema - - schemaRef.setReferencedSchema(referencedSchema); - } - catch (WSDLException e) - { - throw e; - } - catch (RuntimeException e) - { - throw e; + // By this point, we know we have a SchemaDeserializer registered + // so we can safely cast the ExtensibilityElement to a Schema. + referencedSchema = (Schema) parseSchema(parentType, documentElement, dummyDef, extReg); } - catch (Exception e) - { - throw new WSDLException(WSDLException.OTHER_ERROR, - "An error occurred trying to resolve schema referenced at '" - + schemaRef.getSchemaLocationURI() - + "'" - + (schema.getDocumentBaseURI() == null ? "." : ", relative to '" - + schema.getDocumentBaseURI() + "'."), - e); - } - - } //end while loop - - return schema; - - } - catch (WSDLException e) - { - if (e.getLocation() == null) - { + + } // end if referencedSchema + + schemaRef.setReferencedSchema(referencedSchema); + } catch (WSDLException e) { + throw e; + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new WSDLException(WSDLException.OTHER_ERROR, "An error occurred trying to resolve schema referenced at '" + schemaRef.getSchemaLocationURI() + "'" + (schema.getDocumentBaseURI() == null ? "." : ", relative to '" + schema.getDocumentBaseURI() + "'."), e); + } + + } // end while loop + + return schema; + + } catch (WSDLException e) { + if (e.getLocation() == null) { e.setLocation(XPathUtils.getXPathExprFromNode(el)); - } - else - { - //If this method has been called recursively for nested schemas - //the exception location must be built up recursively too so - //prepend this element's xpath to exception location. + } else { + // If this method has been called recursively for nested schemas + // the exception location must be built up recursively too so + // prepend this element's xpath to exception location. String loc = XPathUtils.getXPathExprFromNode(el) + e.getLocation(); e.setLocation(loc); } - throw e; - } - - } + throw e; + } + } - protected Binding parseBinding(Element bindingEl, Definition def) - throws WSDLException - { + protected Binding parseBinding(Element bindingEl, Definition def) throws WSDLException { Binding binding = null; - + List remainingAttrs = DOMUtils.getAttributes(bindingEl); String name = DOMUtils.getAttribute(bindingEl, Constants.ATTR_NAME, remainingAttrs); - QName portTypeName = getQualifiedAttributeValue(bindingEl, - Constants.ATTR_TYPE, - Constants.ELEM_BINDING, - def, - remainingAttrs); - + QName portTypeName = getQualifiedAttributeValue(bindingEl, Constants.ATTR_TYPE, Constants.ELEM_BINDING, def, remainingAttrs); + PortType portType = null; - if (name != null) - { + if (name != null) { QName bindingName = new QName(def.getTargetNamespace(), name); binding = def.getBinding(bindingName); - if (binding == null) - { + if (binding == null) { binding = def.createBinding(); binding.setQName(bindingName); } - } - else - { + } else { binding = def.createBinding(); } // Whether it was retrieved or created, the definition has been found. binding.setUndefined(false); - if (portTypeName != null) - { + if (portTypeName != null) { portType = def.getPortType(portTypeName); - if (portType == null) - { + if (portType == null) { portType = def.createPortType(); portType.setQName(portTypeName); def.addPortType(portType); @@ -965,135 +678,90 @@ protected Binding parseBinding(Element bindingEl, Definition def) binding.setPortType(portType); } - //register any NS decls with the Definition + // register any NS decls with the Definition NamedNodeMap attrs = bindingEl.getAttributes(); registerNSDeclarations(attrs, def); Element tempEl = DOMUtils.getFirstChildElement(bindingEl); - while (tempEl != null) - { - if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl)) - { + while (tempEl != null) { + if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl)) { binding.setDocumentationElement(tempEl); - } - else if (QNameUtils.matches(Constants.Q_ELEM_OPERATION, tempEl)) - { - binding.addBindingOperation(parseBindingOperation(tempEl, - portType, - def)); - } - else - { - binding.addExtensibilityElement(parseExtensibilityElement( - Binding.class, tempEl, def)); + } else if (QNameUtils.matches(Constants.Q_ELEM_OPERATION, tempEl)) { + binding.addBindingOperation(parseBindingOperation(tempEl, portType, def)); + } else { + binding.addExtensibilityElement(parseExtensibilityElement(Binding.class, tempEl, def)); } tempEl = DOMUtils.getNextSiblingElement(tempEl); } parseExtensibilityAttributes(bindingEl, Binding.class, binding, def); - + return binding; } - protected BindingOperation parseBindingOperation( - Element bindingOperationEl, - PortType portType, - Definition def) - throws WSDLException - { + protected BindingOperation parseBindingOperation(Element bindingOperationEl, PortType portType, Definition def) throws WSDLException { BindingOperation bindingOperation = def.createBindingOperation(); - + List remainingAttrs = DOMUtils.getAttributes(bindingOperationEl); - String name = DOMUtils.getAttribute(bindingOperationEl, - Constants.ATTR_NAME, - remainingAttrs); - - if (name != null) - { + String name = DOMUtils.getAttribute(bindingOperationEl, Constants.ATTR_NAME, remainingAttrs); + + if (name != null) { bindingOperation.setName(name); } - //register any NS decls with the Definition + // register any NS decls with the Definition NamedNodeMap attrs = bindingOperationEl.getAttributes(); registerNSDeclarations(attrs, def); Element tempEl = DOMUtils.getFirstChildElement(bindingOperationEl); - while (tempEl != null) - { - if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl)) - { + while (tempEl != null) { + if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl)) { bindingOperation.setDocumentationElement(tempEl); - } - else if (QNameUtils.matches(Constants.Q_ELEM_INPUT, tempEl)) - { + } else if (QNameUtils.matches(Constants.Q_ELEM_INPUT, tempEl)) { bindingOperation.setBindingInput(parseBindingInput(tempEl, def)); - } - else if (QNameUtils.matches(Constants.Q_ELEM_OUTPUT, tempEl)) - { + } else if (QNameUtils.matches(Constants.Q_ELEM_OUTPUT, tempEl)) { bindingOperation.setBindingOutput(parseBindingOutput(tempEl, def)); - } - else if (QNameUtils.matches(Constants.Q_ELEM_FAULT, tempEl)) - { + } else if (QNameUtils.matches(Constants.Q_ELEM_FAULT, tempEl)) { bindingOperation.addBindingFault(parseBindingFault(tempEl, def)); - } - else - { - bindingOperation.addExtensibilityElement( - parseExtensibilityElement(BindingOperation.class, tempEl, def)); + } else { + bindingOperation.addExtensibilityElement(parseExtensibilityElement(BindingOperation.class, tempEl, def)); } tempEl = DOMUtils.getNextSiblingElement(tempEl); } - if (portType != null) - { + if (portType != null) { BindingInput bindingInput = bindingOperation.getBindingInput(); BindingOutput bindingOutput = bindingOperation.getBindingOutput(); - String inputName = (bindingInput != null - ? (bindingInput.getName() != null ? bindingInput.getName() : Constants.NONE) - : null); - String outputName = (bindingOutput != null - ? (bindingOutput.getName() != null ? bindingOutput.getName() : Constants.NONE) - : null); + String inputName = (bindingInput != null ? (bindingInput.getName() != null ? bindingInput.getName() : Constants.NONE) : null); + String outputName = (bindingOutput != null ? (bindingOutput.getName() != null ? bindingOutput.getName() : Constants.NONE) : null); Operation op = portType.getOperation(name, inputName, outputName); - + /* - * If the bindingOp input or output message names are null we will search first - * for a porttypeOp with corresponding unnamed input or output messages (using - * Constants.NONE for inputName or outputName, as above). - * However, input and output message names need not be used at all if operation - * overloading is not used, so if no match was found we will try again ignoring - * these unnamed messages from the search criteria (i.e. using null instead of - * Constants.NONE for inputName or outputName). + * If the bindingOp input or output message names are null we will search first for a porttypeOp with corresponding unnamed input or output messages (using Constants.NONE for inputName or outputName, as above). However, input and output message names need not be used at all if operation + * overloading is not used, so if no match was found we will try again ignoring these unnamed messages from the search criteria (i.e. using null instead of Constants.NONE for inputName or outputName). */ - - if(op == null) - { - if(Constants.NONE.equals(inputName) && Constants.NONE.equals(outputName)) - { - //There was no porttype op with unnamed input and output messages, - //so ignore input and output name and search on the op name only. + + if (op == null) { + if (Constants.NONE.equals(inputName) && Constants.NONE.equals(outputName)) { + // There was no porttype op with unnamed input and output messages, + // so ignore input and output name and search on the op name only. op = portType.getOperation(name, null, null); - } - else if(Constants.NONE.equals(inputName)) - { - //There was no porttype op with an unnamed input message, - //so ignore input name and search on the op name and output name only. + } else if (Constants.NONE.equals(inputName)) { + // There was no porttype op with an unnamed input message, + // so ignore input name and search on the op name and output name only. op = portType.getOperation(name, null, outputName); - } - else if(Constants.NONE.equals(outputName)) - { - //There was no porttype op with an unnamed output message, - //so ignore output name and search on the op name and input name only. + } else if (Constants.NONE.equals(outputName)) { + // There was no porttype op with an unnamed output message, + // so ignore output name and search on the op name and input name only. op = portType.getOperation(name, inputName, null); } } - if (op == null) - { + if (op == null) { Input input = def.createInput(); Output output = def.createOutput(); @@ -1110,84 +778,62 @@ else if(Constants.NONE.equals(outputName)) } parseExtensibilityAttributes(bindingOperationEl, BindingOperation.class, bindingOperation, def); - + return bindingOperation; } - protected BindingInput parseBindingInput(Element bindingInputEl, - Definition def) - throws WSDLException - { + protected BindingInput parseBindingInput(Element bindingInputEl, Definition def) throws WSDLException { BindingInput bindingInput = def.createBindingInput(); - + List remainingAttrs = DOMUtils.getAttributes(bindingInputEl); - String name = DOMUtils.getAttribute(bindingInputEl, - Constants.ATTR_NAME, - remainingAttrs); - - if (name != null) - { + String name = DOMUtils.getAttribute(bindingInputEl, Constants.ATTR_NAME, remainingAttrs); + + if (name != null) { bindingInput.setName(name); } - //register any NS decls with the Definition + // register any NS decls with the Definition NamedNodeMap attrs = bindingInputEl.getAttributes(); registerNSDeclarations(attrs, def); Element tempEl = DOMUtils.getFirstChildElement(bindingInputEl); - while (tempEl != null) - { - if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl)) - { + while (tempEl != null) { + if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl)) { bindingInput.setDocumentationElement(tempEl); - } - else - { - bindingInput.addExtensibilityElement( - parseExtensibilityElement(BindingInput.class, tempEl, def)); + } else { + bindingInput.addExtensibilityElement(parseExtensibilityElement(BindingInput.class, tempEl, def)); } tempEl = DOMUtils.getNextSiblingElement(tempEl); } - + parseExtensibilityAttributes(bindingInputEl, BindingInput.class, bindingInput, def); - + return bindingInput; } - protected BindingOutput parseBindingOutput(Element bindingOutputEl, - Definition def) - throws WSDLException - { + protected BindingOutput parseBindingOutput(Element bindingOutputEl, Definition def) throws WSDLException { BindingOutput bindingOutput = def.createBindingOutput(); - + List remainingAttrs = DOMUtils.getAttributes(bindingOutputEl); - String name = DOMUtils.getAttribute(bindingOutputEl, - Constants.ATTR_NAME, - remainingAttrs); - - if (name != null) - { + String name = DOMUtils.getAttribute(bindingOutputEl, Constants.ATTR_NAME, remainingAttrs); + + if (name != null) { bindingOutput.setName(name); } - //register any NS decls with the Definition + // register any NS decls with the Definition NamedNodeMap attrs = bindingOutputEl.getAttributes(); registerNSDeclarations(attrs, def); Element tempEl = DOMUtils.getFirstChildElement(bindingOutputEl); - while (tempEl != null) - { - if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl)) - { + while (tempEl != null) { + if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl)) { bindingOutput.setDocumentationElement(tempEl); - } - else - { - bindingOutput.addExtensibilityElement( - parseExtensibilityElement(BindingOutput.class, tempEl, def)); + } else { + bindingOutput.addExtensibilityElement(parseExtensibilityElement(BindingOutput.class, tempEl, def)); } tempEl = DOMUtils.getNextSiblingElement(tempEl); @@ -1198,151 +844,111 @@ protected BindingOutput parseBindingOutput(Element bindingOutputEl, return bindingOutput; } - protected BindingFault parseBindingFault(Element bindingFaultEl, - Definition def) - throws WSDLException - { + protected BindingFault parseBindingFault(Element bindingFaultEl, Definition def) throws WSDLException { BindingFault bindingFault = def.createBindingFault(); - + List remainingAttrs = DOMUtils.getAttributes(bindingFaultEl); - String name = DOMUtils.getAttribute(bindingFaultEl, - Constants.ATTR_NAME, - remainingAttrs); - - if (name != null) - { + String name = DOMUtils.getAttribute(bindingFaultEl, Constants.ATTR_NAME, remainingAttrs); + + if (name != null) { bindingFault.setName(name); } - //register any NS decls with the Definition + // register any NS decls with the Definition NamedNodeMap attrs = bindingFaultEl.getAttributes(); registerNSDeclarations(attrs, def); Element tempEl = DOMUtils.getFirstChildElement(bindingFaultEl); - while (tempEl != null) - { - if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl)) - { + while (tempEl != null) { + if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl)) { bindingFault.setDocumentationElement(tempEl); - } - else - { - bindingFault.addExtensibilityElement( - parseExtensibilityElement(BindingFault.class, tempEl, def)); + } else { + bindingFault.addExtensibilityElement(parseExtensibilityElement(BindingFault.class, tempEl, def)); } tempEl = DOMUtils.getNextSiblingElement(tempEl); } parseExtensibilityAttributes(bindingFaultEl, BindingFault.class, bindingFault, def); - + return bindingFault; } - protected Message parseMessage(Element msgEl, Definition def) - throws WSDLException - { + protected Message parseMessage(Element msgEl, Definition def) throws WSDLException { Message msg = null; - + List remainingAttrs = DOMUtils.getAttributes(msgEl); String name = DOMUtils.getAttribute(msgEl, Constants.ATTR_NAME, remainingAttrs); - - if (name != null) - { + + if (name != null) { QName messageName = new QName(def.getTargetNamespace(), name); msg = def.getMessage(messageName); - if (msg == null) - { + if (msg == null) { msg = def.createMessage(); msg.setQName(messageName); } - } - else - { + } else { msg = def.createMessage(); } // Whether it was retrieved or created, the definition has been found. msg.setUndefined(false); - //register any NS decls with the Definition + // register any NS decls with the Definition NamedNodeMap attrs = msgEl.getAttributes(); registerNSDeclarations(attrs, def); Element tempEl = DOMUtils.getFirstChildElement(msgEl); - while (tempEl != null) - { - if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl)) - { + while (tempEl != null) { + if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl)) { msg.setDocumentationElement(tempEl); - } - else if (QNameUtils.matches(Constants.Q_ELEM_PART, tempEl)) - { + } else if (QNameUtils.matches(Constants.Q_ELEM_PART, tempEl)) { msg.addPart(parsePart(tempEl, def)); - } - else - { - msg.addExtensibilityElement( - parseExtensibilityElement(Message.class, tempEl, def)); + } else { + msg.addExtensibilityElement(parseExtensibilityElement(Message.class, tempEl, def)); } tempEl = DOMUtils.getNextSiblingElement(tempEl); } parseExtensibilityAttributes(msgEl, Message.class, msg, def); - + return msg; } - protected Part parsePart(Element partEl, Definition def) - throws WSDLException - { + protected Part parsePart(Element partEl, Definition def) throws WSDLException { Part part = def.createPart(); String name = DOMUtils.getAttribute(partEl, Constants.ATTR_NAME); - QName elementName = getQualifiedAttributeValue(partEl, - Constants.ATTR_ELEMENT, - Constants.ELEM_MESSAGE, - def); - QName typeName = getQualifiedAttributeValue(partEl, - Constants.ATTR_TYPE, - Constants.ELEM_MESSAGE, - def); - - if (name != null) - { + QName elementName = getQualifiedAttributeValue(partEl, Constants.ATTR_ELEMENT, Constants.ELEM_MESSAGE, def); + QName typeName = getQualifiedAttributeValue(partEl, Constants.ATTR_TYPE, Constants.ELEM_MESSAGE, def); + + if (name != null) { part.setName(name); } - if (elementName != null) - { + if (elementName != null) { part.setElementName(elementName); } - if (typeName != null) - { + if (typeName != null) { part.setTypeName(typeName); } - //register any NS decls with the Definition + // register any NS decls with the Definition NamedNodeMap attrs = partEl.getAttributes(); registerNSDeclarations(attrs, def); Element tempEl = DOMUtils.getFirstChildElement(partEl); - while (tempEl != null) - { - if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl)) - { + while (tempEl != null) { + if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl)) { part.setDocumentationElement(tempEl); - } - else - { - part.addExtensibilityElement( - parseExtensibilityElement(Part.class, tempEl, def)); + } else { + part.addExtensibilityElement(parseExtensibilityElement(Part.class, tempEl, def)); } tempEl = DOMUtils.getNextSiblingElement(tempEl); @@ -1353,38 +959,30 @@ protected Part parsePart(Element partEl, Definition def) return part; } - protected void parseExtensibilityAttributes(Element el, - Class parentType, - AttributeExtensible attrExt, - Definition def) - throws WSDLException - { - if (attrExt == null) return; - + protected void parseExtensibilityAttributes(Element el, Class parentType, AttributeExtensible attrExt, Definition def) throws WSDLException { + if (attrExt == null) + return; + List nativeAttributeNames = attrExt.getNativeAttributeNames(); NamedNodeMap nodeMap = el.getAttributes(); int length = nodeMap.getLength(); - for (int i = 0; i < length; i++) - { - Attr attribute = (Attr)nodeMap.item(i); + for (int i = 0; i < length; i++) { + Attr attribute = (Attr) nodeMap.item(i); String localName = attribute.getLocalName(); String namespaceURI = attribute.getNamespaceURI(); String prefix = attribute.getPrefix(); QName qname = new QName(namespaceURI, localName); - if (namespaceURI != null && !namespaceURI.equals(Constants.NS_URI_WSDL)) - { - if (!namespaceURI.equals(Constants.NS_URI_XMLNS)) - { + if (namespaceURI != null && !namespaceURI.equals(Constants.NS_URI_WSDL)) { + if (!namespaceURI.equals(Constants.NS_URI_XMLNS)) { DOMUtils.registerUniquePrefix(prefix, namespaceURI, def); String strValue = attribute.getValue(); int attrType = AttributeExtensible.NO_DECLARED_TYPE; ExtensionRegistry extReg = def.getExtensionRegistry(); - if (extReg != null) - { + if (extReg != null) { attrType = extReg.queryExtensionAttributeType(parentType, qname); } @@ -1392,16 +990,8 @@ protected void parseExtensibilityAttributes(Element el, attrExt.setExtensionAttribute(qname, val); } - } - else if (!nativeAttributeNames.contains(localName)) - { - WSDLException wsdlExc = new WSDLException(WSDLException.INVALID_WSDL, - "Encountered illegal " + - "extension attribute '" + - qname + "'. Extension " + - "attributes must be in " + - "a namespace other than " + - "WSDL's."); + } else if (!nativeAttributeNames.contains(localName)) { + WSDLException wsdlExc = new WSDLException(WSDLException.INVALID_WSDL, "Encountered illegal " + "extension attribute '" + qname + "'. Extension " + "attributes must be in " + "a namespace other than " + "WSDL's."); wsdlExc.setLocation(XPathUtils.getXPathExprFromNode(el)); @@ -1410,50 +1000,32 @@ else if (!nativeAttributeNames.contains(localName)) } } - protected Object parseExtensibilityAttribute(Element el, - int attrType, - String attrValue, - Definition def) - throws WSDLException - { - if (attrType == AttributeExtensible.QNAME_TYPE) - { + protected Object parseExtensibilityAttribute(Element el, int attrType, String attrValue, Definition def) throws WSDLException { + if (attrType == AttributeExtensible.QNAME_TYPE) { return DOMUtils.getQName(attrValue, el, def); - } - else if (attrType == AttributeExtensible.LIST_OF_STRINGS_TYPE) - { + } else if (attrType == AttributeExtensible.LIST_OF_STRINGS_TYPE) { return StringUtils.parseNMTokens(attrValue); - } - else if (attrType == AttributeExtensible.LIST_OF_QNAMES_TYPE) - { + } else if (attrType == AttributeExtensible.LIST_OF_QNAMES_TYPE) { List oldList = StringUtils.parseNMTokens(attrValue); int size = oldList.size(); List newList = new Vector(size); - for (int i = 0; i < size; i++) - { - String str = (String)oldList.get(i); + for (int i = 0; i < size; i++) { + String str = (String) oldList.get(i); QName qValue = DOMUtils.getQName(str, el, def); newList.add(qValue); } return newList; - } - else if (attrType == AttributeExtensible.STRING_TYPE) - { + } else if (attrType == AttributeExtensible.STRING_TYPE) { return attrValue; - } - else - { + } else { QName qValue = null; - try - { + try { qValue = DOMUtils.getQName(attrValue, el, def); - } - catch (WSDLException e) - { + } catch (WSDLException e) { qValue = new QName(attrValue); } @@ -1461,57 +1033,43 @@ else if (attrType == AttributeExtensible.STRING_TYPE) } } - protected PortType parsePortType(Element portTypeEl, Definition def) - throws WSDLException - { + protected PortType parsePortType(Element portTypeEl, Definition def) throws WSDLException { PortType portType = null; String name = DOMUtils.getAttribute(portTypeEl, Constants.ATTR_NAME); - if (name != null) - { + if (name != null) { QName portTypeName = new QName(def.getTargetNamespace(), name); portType = def.getPortType(portTypeName); - if (portType == null) - { + if (portType == null) { portType = def.createPortType(); portType.setQName(portTypeName); } - } - else - { + } else { portType = def.createPortType(); } // Whether it was retrieved or created, the definition has been found. portType.setUndefined(false); - //register any NS decls with the Definition + // register any NS decls with the Definition NamedNodeMap attrs = portTypeEl.getAttributes(); registerNSDeclarations(attrs, def); Element tempEl = DOMUtils.getFirstChildElement(portTypeEl); - while (tempEl != null) - { - if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl)) - { + while (tempEl != null) { + if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl)) { portType.setDocumentationElement(tempEl); - } - else if (QNameUtils.matches(Constants.Q_ELEM_OPERATION, tempEl)) - { + } else if (QNameUtils.matches(Constants.Q_ELEM_OPERATION, tempEl)) { Operation op = parseOperation(tempEl, portType, def); - if (op != null) - { + if (op != null) { portType.addOperation(op); } - } - else - { - portType.addExtensibilityElement( - parseExtensibilityElement(PortType.class, tempEl, def)); + } else { + portType.addExtensibilityElement(parseExtensibilityElement(PortType.class, tempEl, def)); } tempEl = DOMUtils.getNextSiblingElement(tempEl); @@ -1522,20 +1080,14 @@ else if (QNameUtils.matches(Constants.Q_ELEM_OPERATION, tempEl)) return portType; } - protected Operation parseOperation(Element opEl, - PortType portType, - Definition def) - throws WSDLException - { + protected Operation parseOperation(Element opEl, PortType portType, Definition def) throws WSDLException { Operation op = null; - + List remainingAttrs = DOMUtils.getAttributes(opEl); String name = DOMUtils.getAttribute(opEl, Constants.ATTR_NAME, remainingAttrs); - String parameterOrderStr = DOMUtils.getAttribute(opEl, - Constants.ATTR_PARAMETER_ORDER, - remainingAttrs); - - //register any NS decls with the Definition + String parameterOrderStr = DOMUtils.getAttribute(opEl, Constants.ATTR_PARAMETER_ORDER, remainingAttrs); + + // register any NS decls with the Definition NamedNodeMap attrs = opEl.getAttributes(); registerNSDeclarations(attrs, def); @@ -1548,92 +1100,64 @@ protected Operation parseOperation(Element opEl, List extElements = new Vector(); boolean retrieved = true; - while (tempEl != null) - { - if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl)) - { + while (tempEl != null) { + if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl)) { docEl = tempEl; - } - else if (QNameUtils.matches(Constants.Q_ELEM_INPUT, tempEl)) - { + } else if (QNameUtils.matches(Constants.Q_ELEM_INPUT, tempEl)) { input = parseInput(tempEl, def); messageOrder.add(Constants.ELEM_INPUT); - } - else if (QNameUtils.matches(Constants.Q_ELEM_OUTPUT, tempEl)) - { + } else if (QNameUtils.matches(Constants.Q_ELEM_OUTPUT, tempEl)) { output = parseOutput(tempEl, def); messageOrder.add(Constants.ELEM_OUTPUT); - } - else if (QNameUtils.matches(Constants.Q_ELEM_FAULT, tempEl)) - { + } else if (QNameUtils.matches(Constants.Q_ELEM_FAULT, tempEl)) { faults.add(parseFault(tempEl, def)); - } - else - { - extElements.add( - parseExtensibilityElement(Operation.class, tempEl, def)); + } else { + extElements.add(parseExtensibilityElement(Operation.class, tempEl, def)); } tempEl = DOMUtils.getNextSiblingElement(tempEl); } - if (name != null) - { - String inputName = (input != null - ? (input.getName() != null ? input.getName() : Constants.NONE) - : null); - String outputName = (output != null - ? (output.getName() != null ? output.getName() : Constants.NONE) - : null); + if (name != null) { + String inputName = (input != null ? (input.getName() != null ? input.getName() : Constants.NONE) : null); + String outputName = (output != null ? (output.getName() != null ? output.getName() : Constants.NONE) : null); op = portType.getOperation(name, inputName, outputName); - if (op != null && !op.isUndefined()) - { + if (op != null && !op.isUndefined()) { op = null; } - if (op != null) - { - if (inputName == null) - { + if (op != null) { + if (inputName == null) { Input tempIn = op.getInput(); - if (tempIn != null) - { - if (tempIn.getName() != null) - { + if (tempIn != null) { + if (tempIn.getName() != null) { op = null; } } } } - if (op != null) - { - if (outputName == null) - { + if (op != null) { + if (outputName == null) { Output tempOut = op.getOutput(); - if (tempOut != null) - { - if (tempOut.getName() != null) - { + if (tempOut != null) { + if (tempOut.getName() != null) { op = null; } } } } - if (op == null) - { + if (op == null) { op = def.createOperation(); op.setName(name); retrieved = false; } - } - else - { + } else { op = def.createOperation(); retrieved = false; } @@ -1641,148 +1165,111 @@ else if (QNameUtils.matches(Constants.Q_ELEM_FAULT, tempEl)) // Whether it was retrieved or created, the definition has been found. op.setUndefined(false); - if (parameterOrderStr != null) - { + if (parameterOrderStr != null) { op.setParameterOrdering(StringUtils.parseNMTokens(parameterOrderStr)); } - if (docEl != null) - { + if (docEl != null) { op.setDocumentationElement(docEl); } - if (input != null) - { + if (input != null) { op.setInput(input); } - if (output != null) - { + if (output != null) { op.setOutput(output); } - if (faults.size() > 0) - { + if (faults.size() > 0) { Iterator faultIterator = faults.iterator(); - while (faultIterator.hasNext()) - { - op.addFault((Fault)faultIterator.next()); + while (faultIterator.hasNext()) { + op.addFault((Fault) faultIterator.next()); } } - if (extElements.size() > 0) - { + if (extElements.size() > 0) { Iterator eeIterator = extElements.iterator(); - - while (eeIterator.hasNext()) - { - op.addExtensibilityElement( - (ExtensibilityElement) eeIterator.next() ); + + while (eeIterator.hasNext()) { + op.addExtensibilityElement((ExtensibilityElement) eeIterator.next()); } } - + OperationType style = null; - if (messageOrder.equals(STYLE_ONE_WAY)) - { + if (messageOrder.equals(STYLE_ONE_WAY)) { style = OperationType.ONE_WAY; - } - else if (messageOrder.equals(STYLE_REQUEST_RESPONSE)) - { + } else if (messageOrder.equals(STYLE_REQUEST_RESPONSE)) { style = OperationType.REQUEST_RESPONSE; - } - else if (messageOrder.equals(STYLE_SOLICIT_RESPONSE)) - { + } else if (messageOrder.equals(STYLE_SOLICIT_RESPONSE)) { style = OperationType.SOLICIT_RESPONSE; - } - else if (messageOrder.equals(STYLE_NOTIFICATION)) - { + } else if (messageOrder.equals(STYLE_NOTIFICATION)) { style = OperationType.NOTIFICATION; } - if (style != null) - { + if (style != null) { op.setStyle(style); } parseExtensibilityAttributes(opEl, Operation.class, op, def); - - if (retrieved) - { + + if (retrieved) { op = null; } return op; } - protected Service parseService(Element serviceEl, Definition def) - throws WSDLException - { + protected Service parseService(Element serviceEl, Definition def) throws WSDLException { Service service = def.createService(); - + List remainingAttrs = DOMUtils.getAttributes(serviceEl); String name = DOMUtils.getAttribute(serviceEl, Constants.ATTR_NAME, remainingAttrs); - - if (name != null) - { + + if (name != null) { service.setQName(new QName(def.getTargetNamespace(), name)); } - //register any NS decls with the Definition + // register any NS decls with the Definition NamedNodeMap attrs = serviceEl.getAttributes(); registerNSDeclarations(attrs, def); Element tempEl = DOMUtils.getFirstChildElement(serviceEl); - while (tempEl != null) - { - if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl)) - { + while (tempEl != null) { + if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl)) { service.setDocumentationElement(tempEl); - } - else if (QNameUtils.matches(Constants.Q_ELEM_PORT, tempEl)) - { + } else if (QNameUtils.matches(Constants.Q_ELEM_PORT, tempEl)) { service.addPort(parsePort(tempEl, def)); - } - else - { - service.addExtensibilityElement( - parseExtensibilityElement(Service.class, tempEl, def)); + } else { + service.addExtensibilityElement(parseExtensibilityElement(Service.class, tempEl, def)); } tempEl = DOMUtils.getNextSiblingElement(tempEl); } parseExtensibilityAttributes(serviceEl, Service.class, service, def); - + return service; } - protected Port parsePort(Element portEl, Definition def) - throws WSDLException - { + protected Port parsePort(Element portEl, Definition def) throws WSDLException { Port port = def.createPort(); - + List remainingAttrs = DOMUtils.getAttributes(portEl); String name = DOMUtils.getAttribute(portEl, Constants.ATTR_NAME, remainingAttrs); - QName bindingStr = getQualifiedAttributeValue(portEl, - Constants.ATTR_BINDING, - Constants.ELEM_PORT, - def, - remainingAttrs); - - if (name != null) - { + QName bindingStr = getQualifiedAttributeValue(portEl, Constants.ATTR_BINDING, Constants.ELEM_PORT, def, remainingAttrs); + + if (name != null) { port.setName(name); } - if (bindingStr != null) - { + if (bindingStr != null) { Binding binding = def.getBinding(bindingStr); - if (binding == null) - { + if (binding == null) { binding = def.createBinding(); binding.setQName(bindingStr); def.addBinding(binding); @@ -1791,79 +1278,50 @@ protected Port parsePort(Element portEl, Definition def) port.setBinding(binding); } - //register any NS decls with the Definition + // register any NS decls with the Definition NamedNodeMap attrs = portEl.getAttributes(); registerNSDeclarations(attrs, def); Element tempEl = DOMUtils.getFirstChildElement(portEl); - while (tempEl != null) - { - if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl)) - { + while (tempEl != null) { + if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl)) { port.setDocumentationElement(tempEl); - } - else - { - port.addExtensibilityElement(parseExtensibilityElement(Port.class, - tempEl, - def)); + } else { + port.addExtensibilityElement(parseExtensibilityElement(Port.class, tempEl, def)); } tempEl = DOMUtils.getNextSiblingElement(tempEl); } parseExtensibilityAttributes(portEl, Port.class, port, def); - + return port; } - protected ExtensibilityElement parseExtensibilityElement( - Class parentType, - Element el, - Definition def) - throws WSDLException - { + protected ExtensibilityElement parseExtensibilityElement(Class parentType, Element el, Definition def) throws WSDLException { QName elementType = QNameUtils.newQName(el); - + String namespaceURI = el.getNamespaceURI(); - try - { - if (namespaceURI == null || namespaceURI.equals(Constants.NS_URI_WSDL)) - { - throw new WSDLException(WSDLException.INVALID_WSDL, - "Encountered illegal extension element '" + - elementType + - "' in the context of a '" + - parentType.getName() + - "'. Extension elements must be in " + - "a namespace other than WSDL's."); + try { + if (namespaceURI == null || namespaceURI.equals(Constants.NS_URI_WSDL)) { + throw new WSDLException(WSDLException.INVALID_WSDL, "Encountered illegal extension element '" + elementType + "' in the context of a '" + parentType.getName() + "'. Extension elements must be in " + "a namespace other than WSDL's."); } - + ExtensionRegistry extReg = def.getExtensionRegistry(); - if (extReg == null) - { - throw new WSDLException(WSDLException.CONFIGURATION_ERROR, - "No ExtensionRegistry set for this " + - "Definition, so unable to deserialize " + - "a '" + elementType + "' element in the " + - "context of a '" + parentType.getName() + - "'."); + if (extReg == null) { + throw new WSDLException(WSDLException.CONFIGURATION_ERROR, "No ExtensionRegistry set for this " + "Definition, so unable to deserialize " + "a '" + elementType + "' element in the " + "context of a '" + parentType.getName() + "'."); } - ExtensionDeserializer extDS = extReg.queryDeserializer(parentType, - elementType); + ExtensionDeserializer extDS = extReg.queryDeserializer(parentType, elementType); NamedNodeMap attrs = el.getAttributes(); registerNSDeclarations(attrs, def); - + return extDS.unmarshall(parentType, elementType, el, def, extReg); - } - catch (WSDLException e) - { - if (e.getLocation() == null) - { + } catch (WSDLException e) { + if (e.getLocation() == null) { e.setLocation(XPathUtils.getXPathExprFromNode(el)); } @@ -1872,81 +1330,58 @@ protected ExtensibilityElement parseExtensibilityElement( } /** - * Parse the element using the ExtensionRegistry default deserializer instead using the one - * registered. The default deserializer will create an UnknownExtensibilityElement from the element. + * Parse the element using the ExtensionRegistry default deserializer instead using the one registered. The default deserializer will create an UnknownExtensibilityElement from the element. + * * @param parentType * @param el * @param def - * @return An instance of the default ExtensibilityElement as registered with the ExtensionRegistry + * @return An instance of the default ExtensibilityElement as registered with the ExtensionRegistry * @throws WSDLException */ - protected ExtensibilityElement parseExtensibilityElementAsDefaultExtensiblityElement( - Class parentType, Element el, Definition def) throws WSDLException - { + protected ExtensibilityElement parseExtensibilityElementAsDefaultExtensiblityElement(Class parentType, Element el, Definition def) throws WSDLException { QName elementType = QNameUtils.newQName(el); String namespaceURI = el.getNamespaceURI(); - try - { - if (namespaceURI == null || namespaceURI.equals(Constants.NS_URI_WSDL)) - { - throw new WSDLException(WSDLException.INVALID_WSDL, - "Encountered illegal extension element '" + elementType - + "' in the context of a '" + parentType.getName() - + "'. Extension elements must be in " - + "a namespace other than WSDL's."); + try { + if (namespaceURI == null || namespaceURI.equals(Constants.NS_URI_WSDL)) { + throw new WSDLException(WSDLException.INVALID_WSDL, "Encountered illegal extension element '" + elementType + "' in the context of a '" + parentType.getName() + "'. Extension elements must be in " + "a namespace other than WSDL's."); } ExtensionRegistry extReg = def.getExtensionRegistry(); - if (extReg == null) - { - throw new WSDLException(WSDLException.CONFIGURATION_ERROR, - "No ExtensionRegistry set for this " - + "Definition, so unable to deserialize " + "a '" + elementType - + "' element in the " + "context of a '" + parentType.getName() - + "'."); + if (extReg == null) { + throw new WSDLException(WSDLException.CONFIGURATION_ERROR, "No ExtensionRegistry set for this " + "Definition, so unable to deserialize " + "a '" + elementType + "' element in the " + "context of a '" + parentType.getName() + "'."); } ExtensionDeserializer extDS = extReg.getDefaultDeserializer(); - + NamedNodeMap attrs = el.getAttributes(); registerNSDeclarations(attrs, def); - + return extDS.unmarshall(parentType, elementType, el, def, extReg); - } catch (WSDLException e) - { - if (e.getLocation() == null) - { + } catch (WSDLException e) { + if (e.getLocation() == null) { e.setLocation(XPathUtils.getXPathExprFromNode(el)); } throw e; } } - - protected Input parseInput(Element inputEl, Definition def) - throws WSDLException - { + + protected Input parseInput(Element inputEl, Definition def) throws WSDLException { Input input = def.createInput(); String name = DOMUtils.getAttribute(inputEl, Constants.ATTR_NAME); - QName messageName = getQualifiedAttributeValue(inputEl, - Constants.ATTR_MESSAGE, - Constants.ELEM_INPUT, - def); + QName messageName = getQualifiedAttributeValue(inputEl, Constants.ATTR_MESSAGE, Constants.ELEM_INPUT, def); - if (name != null) - { + if (name != null) { input.setName(name); } - if (messageName != null) - { + if (messageName != null) { Message message = def.getMessage(messageName); - if (message == null) - { + if (message == null) { message = def.createMessage(); message.setQName(messageName); def.addMessage(message); @@ -1955,22 +1390,17 @@ protected Input parseInput(Element inputEl, Definition def) input.setMessage(message); } - //register any NS decls with the Definition + // register any NS decls with the Definition NamedNodeMap attrs = inputEl.getAttributes(); registerNSDeclarations(attrs, def); Element tempEl = DOMUtils.getFirstChildElement(inputEl); - while (tempEl != null) - { - if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl)) - { + while (tempEl != null) { + if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl)) { input.setDocumentationElement(tempEl); - } - else - { - input.addExtensibilityElement( - parseExtensibilityElement(Input.class, tempEl, def)); + } else { + input.addExtensibilityElement(parseExtensibilityElement(Input.class, tempEl, def)); } tempEl = DOMUtils.getNextSiblingElement(tempEl); @@ -1981,27 +1411,19 @@ protected Input parseInput(Element inputEl, Definition def) return input; } - protected Output parseOutput(Element outputEl, Definition def) - throws WSDLException - { + protected Output parseOutput(Element outputEl, Definition def) throws WSDLException { Output output = def.createOutput(); String name = DOMUtils.getAttribute(outputEl, Constants.ATTR_NAME); - QName messageName = getQualifiedAttributeValue(outputEl, - Constants.ATTR_MESSAGE, - Constants.ELEM_OUTPUT, - def); + QName messageName = getQualifiedAttributeValue(outputEl, Constants.ATTR_MESSAGE, Constants.ELEM_OUTPUT, def); - if (name != null) - { + if (name != null) { output.setName(name); } - if (messageName != null) - { + if (messageName != null) { Message message = def.getMessage(messageName); - if (message == null) - { + if (message == null) { message = def.createMessage(); message.setQName(messageName); def.addMessage(message); @@ -2010,22 +1432,17 @@ protected Output parseOutput(Element outputEl, Definition def) output.setMessage(message); } - //register any NS decls with the Definition + // register any NS decls with the Definition NamedNodeMap attrs = outputEl.getAttributes(); registerNSDeclarations(attrs, def); Element tempEl = DOMUtils.getFirstChildElement(outputEl); - while (tempEl != null) - { - if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl)) - { + while (tempEl != null) { + if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl)) { output.setDocumentationElement(tempEl); - } - else - { - output.addExtensibilityElement( - parseExtensibilityElement(Output.class, tempEl, def)); + } else { + output.addExtensibilityElement(parseExtensibilityElement(Output.class, tempEl, def)); } tempEl = DOMUtils.getNextSiblingElement(tempEl); @@ -2036,27 +1453,19 @@ protected Output parseOutput(Element outputEl, Definition def) return output; } - protected Fault parseFault(Element faultEl, Definition def) - throws WSDLException - { + protected Fault parseFault(Element faultEl, Definition def) throws WSDLException { Fault fault = def.createFault(); String name = DOMUtils.getAttribute(faultEl, Constants.ATTR_NAME); - QName messageName = getQualifiedAttributeValue(faultEl, - Constants.ATTR_MESSAGE, - Constants.ELEM_FAULT, - def); + QName messageName = getQualifiedAttributeValue(faultEl, Constants.ATTR_MESSAGE, Constants.ELEM_FAULT, def); - if (name != null) - { + if (name != null) { fault.setName(name); } - if (messageName != null) - { + if (messageName != null) { Message message = def.getMessage(messageName); - if (message == null) - { + if (message == null) { message = def.createMessage(); message.setQName(messageName); def.addMessage(message); @@ -2065,22 +1474,17 @@ protected Fault parseFault(Element faultEl, Definition def) fault.setMessage(message); } - //register any NS decls with the Definition + // register any NS decls with the Definition NamedNodeMap attrs = faultEl.getAttributes(); registerNSDeclarations(attrs, def); Element tempEl = DOMUtils.getFirstChildElement(faultEl); - while (tempEl != null) - { - if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl)) - { + while (tempEl != null) { + if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl)) { fault.setDocumentationElement(tempEl); - } - else - { - fault.addExtensibilityElement( - parseExtensibilityElement(Fault.class, tempEl, def)); + } else { + fault.addExtensibilityElement(parseExtensibilityElement(Fault.class, tempEl, def)); } tempEl = DOMUtils.getNextSiblingElement(tempEl); @@ -2092,81 +1496,42 @@ protected Fault parseFault(Element faultEl, Definition def) } /** - * This method should be used for elements that support extension - * attributes because it does not track unexpected remaining attributes. + * This method should be used for elements that support extension attributes because it does not track unexpected remaining attributes. */ - private static QName getQualifiedAttributeValue(Element el, - String attrName, - String elDesc, - Definition def) - throws WSDLException - { - try - { - return DOMUtils.getQualifiedAttributeValue(el, - attrName, - elDesc, - false, - def); - } - catch (WSDLException e) - { - if (e.getFaultCode().equals(WSDLException.NO_PREFIX_SPECIFIED)) - { + private static QName getQualifiedAttributeValue(Element el, String attrName, String elDesc, Definition def) throws WSDLException { + try { + return DOMUtils.getQualifiedAttributeValue(el, attrName, elDesc, false, def); + } catch (WSDLException e) { + if (e.getFaultCode().equals(WSDLException.NO_PREFIX_SPECIFIED)) { String attrValue = DOMUtils.getAttribute(el, attrName); return new QName(attrValue); - } - else - { + } else { throw e; } } } - + /** - * This method should be used for elements that do not support extension - * attributes because it tracks unexpected remaining attributes. + * This method should be used for elements that do not support extension attributes because it tracks unexpected remaining attributes. */ - private static QName getQualifiedAttributeValue(Element el, - String attrName, - String elDesc, - Definition def, - List remainingAttrs) - throws WSDLException - { - try - { - return DOMUtils.getQualifiedAttributeValue(el, - attrName, - elDesc, - false, - def, - remainingAttrs); - } - catch (WSDLException e) - { - if (e.getFaultCode().equals(WSDLException.NO_PREFIX_SPECIFIED)) - { + private static QName getQualifiedAttributeValue(Element el, String attrName, String elDesc, Definition def, List remainingAttrs) throws WSDLException { + try { + return DOMUtils.getQualifiedAttributeValue(el, attrName, elDesc, false, def, remainingAttrs); + } catch (WSDLException e) { + if (e.getFaultCode().equals(WSDLException.NO_PREFIX_SPECIFIED)) { String attrValue = DOMUtils.getAttribute(el, attrName, remainingAttrs); return new QName(attrValue); - } - else - { + } else { throw e; } } } - private static void checkElementName(Element el, QName qname) - throws WSDLException - { - if (!QNameUtils.matches(qname, el)) - { - WSDLException wsdlExc = new WSDLException(WSDLException.INVALID_WSDL, - "Expected element '" + - qname + "'."); + private static void checkElementName(Element el, QName qname) throws WSDLException { + if (!QNameUtils.matches(qname, el)) { + WSDLException wsdlExc = new WSDLException(WSDLException.INVALID_WSDL, "Expected element '" + qname + "'."); wsdlExc.setLocation(XPathUtils.getXPathExprFromNode(el)); @@ -2174,98 +1539,70 @@ private static void checkElementName(Element el, QName qname) } } - private static Document getDocument(InputSource inputSource, - String desc) throws WSDLException - { + private static Document getDocument(InputSource inputSource, String desc) throws WSDLException { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); factory.setValidating(false); - try - { + try { DocumentBuilder builder = factory.newDocumentBuilder(); Document doc = builder.parse(inputSource); return doc; - } - catch (RuntimeException e) - { + } catch (RuntimeException e) { throw e; - } - catch (Exception e) - { - throw new WSDLException(WSDLException.PARSER_ERROR, - "Problem parsing '" + desc + "'.", - e); + } catch (Exception e) { + throw new WSDLException(WSDLException.PARSER_ERROR, "Problem parsing '" + desc + "'.", e); } } - private static void registerNSDeclarations(NamedNodeMap attrs, Definition def) - { - int size = attrs.getLength(); - - for (int i = 0; i < size; i++) - { - Attr attr = (Attr)attrs.item(i); - String namespaceURI = attr.getNamespaceURI(); - String localPart = attr.getLocalName(); - String value = attr.getValue(); - - if (namespaceURI != null && namespaceURI.equals(Constants.NS_URI_XMLNS)) - { - if (localPart != null && !localPart.equals(Constants.ATTR_XMLNS)) - { - DOMUtils.registerUniquePrefix(localPart, value, def); - } - else - { - DOMUtils.registerUniquePrefix(null, value, def); - } + private static void registerNSDeclarations(NamedNodeMap attrs, Definition def) { + int size = attrs.getLength(); + + for (int i = 0; i < size; i++) { + Attr attr = (Attr) attrs.item(i); + String namespaceURI = attr.getNamespaceURI(); + String localPart = attr.getLocalName(); + String value = attr.getValue(); + + if (namespaceURI != null && namespaceURI.equals(Constants.NS_URI_XMLNS)) { + if (localPart != null && !localPart.equals(Constants.ATTR_XMLNS)) { + DOMUtils.registerUniquePrefix(localPart, value, def); + } else { + DOMUtils.registerUniquePrefix(null, value, def); } } + } } - + /** - * Read the WSDL document accessible via the specified - * URI into a WSDL definition. + * Read the WSDL document accessible via the specified URI into a WSDL definition. * - * @param wsdlURI a URI (can be a filename or URL) pointing to a - * WSDL XML definition. + * @param wsdlURI + * a URI (can be a filename or URL) pointing to a WSDL XML definition. * @return the definition. */ - public Definition readWSDL(String wsdlURI) throws WSDLException - { + public Definition readWSDL(String wsdlURI) throws WSDLException { return readWSDL(null, wsdlURI); } /** - * Read the WSDL document accessible via the specified - * URI into a WSDL definition. + * Read the WSDL document accessible via the specified URI into a WSDL definition. * - * @param contextURI the context in which to resolve the - * wsdlURI, if the wsdlURI is relative. Can be null, in which - * case it will be ignored. - * @param wsdlURI a URI (can be a filename or URL) pointing to a - * WSDL XML definition. + * @param contextURI + * the context in which to resolve the wsdlURI, if the wsdlURI is relative. Can be null, in which case it will be ignored. + * @param wsdlURI + * a URI (can be a filename or URL) pointing to a WSDL XML definition. * @return the definition. */ - public Definition readWSDL(String contextURI, String wsdlURI) - throws WSDLException - { - try - { - if (verbose) - { - System.out.println("Retrieving document at '" + wsdlURI + "'" + - (contextURI == null - ? "." - : ", relative to '" + contextURI + "'.")); + public Definition readWSDL(String contextURI, String wsdlURI) throws WSDLException { + try { + if (verbose) { + System.out.println("Retrieving document at '" + wsdlURI + "'" + (contextURI == null ? "." : ", relative to '" + contextURI + "'.")); } - URL contextURL = (contextURI != null) - ? StringUtils.getURL(null, contextURI) - : null; + URL contextURL = (contextURI != null) ? StringUtils.getURL(null, contextURI) : null; URL url = StringUtils.getURL(contextURL, wsdlURI); InputStream inputStream = StringUtils.getContentAsInputStream(url); InputSource inputSource = new InputSource(inputStream); @@ -2274,155 +1611,103 @@ public Definition readWSDL(String contextURI, String wsdlURI) inputStream.close(); - Definition def = readWSDL(url.toString(), doc); - - return def; - } - catch (WSDLException e) - { - throw e; - } - catch (RuntimeException e) - { + return readWSDL(url.toString(), doc); + } catch (WSDLException | RuntimeException e) { throw e; - } - catch (Exception e) - { - throw new WSDLException(WSDLException.OTHER_ERROR, - "Unable to resolve imported document at '" + - wsdlURI + - (contextURI == null - ? "'." - : "', relative to '" + contextURI + "'.") - , e); + } catch (Exception e) { + throw new WSDLException(WSDLException.OTHER_ERROR, "Unable to resolve imported document at '" + wsdlURI + (contextURI == null ? "'." : "', relative to '" + contextURI + "'."), e); } } /** - * Read the specified <wsdl:definitions> element into a WSDL - * definition. + * Read the specified <wsdl:definitions> element into a WSDL definition. * - * @param documentBaseURI the document base URI of the WSDL definition - * described by the element. Will be set as the documentBaseURI - * of the returned Definition. Can be null, in which case it - * will be ignored. - * @param definitionsElement the <wsdl:definitions> element + * @param documentBaseURI + * the document base URI of the WSDL definition described by the element. Will be set as the documentBaseURI of the returned Definition. Can be null, in which case it will be ignored. + * @param definitionsElement + * the <wsdl:definitions> element * @return the definition described by the element. */ - public Definition readWSDL(String documentBaseURI, - Element definitionsElement) - throws WSDLException - { + public Definition readWSDL(String documentBaseURI, Element definitionsElement) throws WSDLException { return readWSDL(documentBaseURI, definitionsElement, null); } /** - * Read the specified <wsdl:definitions> element into a WSDL - * definition. The WSDLLocator is used to provide the document - * base URIs. The InputSource of the WSDLLocator is ignored, instead - * the WSDL is parsed from the given Element. + * Read the specified <wsdl:definitions> element into a WSDL definition. The WSDLLocator is used to provide the document base URIs. The InputSource of the WSDLLocator is ignored, instead the WSDL is parsed from the given Element. * - * @param locator A WSDLLocator object used to provide - * the document base URI of the WSDL definition described by the - * element. - * @param definitionsElement the <wsdl:definitions> element + * @param locator + * A WSDLLocator object used to provide the document base URI of the WSDL definition described by the element. + * @param definitionsElement + * the <wsdl:definitions> element * @return the definition described by the element. */ - public Definition readWSDL(WSDLLocator locator, - Element definitionsElement) - throws WSDLException - { - try - { + public Definition readWSDL(WSDLLocator locator, Element definitionsElement) throws WSDLException { + try { this.loc = locator; return readWSDL(locator.getBaseURI(), definitionsElement, null); - } - finally - { + } finally { locator.close(); this.loc = null; } } - - protected Definition readWSDL(String documentBaseURI, - Element definitionsElement, - Map importedDefs) - throws WSDLException - { + + protected Definition readWSDL(String documentBaseURI, Element definitionsElement, Map importedDefs) throws WSDLException { return parseDefinitions(documentBaseURI, definitionsElement, importedDefs); } /** * Read the specified WSDL document into a WSDL definition. * - * @param documentBaseURI the document base URI of the WSDL definition - * described by the document. Will be set as the documentBaseURI - * of the returned Definition. Can be null, in which case it - * will be ignored. - * @param wsdlDocument the WSDL document, an XML - * document obeying the WSDL schema. + * @param documentBaseURI + * the document base URI of the WSDL definition described by the document. Will be set as the documentBaseURI of the returned Definition. Can be null, in which case it will be ignored. + * @param wsdlDocument + * the WSDL document, an XML document obeying the WSDL schema. * @return the definition described in the document. */ - public Definition readWSDL(String documentBaseURI, Document wsdlDocument) - throws WSDLException - { + public Definition readWSDL(String documentBaseURI, Document wsdlDocument) throws WSDLException { return readWSDL(documentBaseURI, wsdlDocument.getDocumentElement()); } /** * Read a WSDL document into a WSDL definition. * - * @param documentBaseURI the document base URI of the WSDL definition - * described by the document. Will be set as the documentBaseURI - * of the returned Definition. Can be null, in which case it - * will be ignored. - * @param inputSource an InputSource pointing to the - * WSDL document, an XML document obeying the WSDL schema. - * @return the definition described in the document pointed to - * by the InputSource. + * @param documentBaseURI + * the document base URI of the WSDL definition described by the document. Will be set as the documentBaseURI of the returned Definition. Can be null, in which case it will be ignored. + * @param inputSource + * an InputSource pointing to the WSDL document, an XML document obeying the WSDL schema. + * @return the definition described in the document pointed to by the InputSource. */ - public Definition readWSDL(String documentBaseURI, InputSource inputSource) - throws WSDLException - { - String location = (inputSource.getSystemId() != null ? - inputSource.getSystemId() : "- WSDL Document -"); - - return readWSDL(documentBaseURI, - getDocument(inputSource, location)); + public Definition readWSDL(String documentBaseURI, InputSource inputSource) throws WSDLException { + String location = (inputSource.getSystemId() != null ? inputSource.getSystemId() : "- WSDL Document -"); + + return readWSDL(documentBaseURI, getDocument(inputSource, location)); } /** * Read a WSDL document into a WSDL definition. * - * @param locator A WSDLLocator object used to provide InputSources - * pointing to the wsdl file. + * @param locator + * A WSDLLocator object used to provide InputSources pointing to the wsdl file. * @return the definition described in the document */ - public Definition readWSDL(WSDLLocator locator) throws WSDLException - { + public Definition readWSDL(WSDLLocator locator) throws WSDLException { InputSource is = locator.getBaseInputSource(); String base = locator.getBaseURI(); - if (is == null) - { - throw new WSDLException(WSDLException.OTHER_ERROR, - "Unable to locate document at '" + base + "'."); + if (is == null) { + throw new WSDLException(WSDLException.OTHER_ERROR, "Unable to locate document at '" + base + "'."); } is.setSystemId(base); this.loc = locator; - if (verbose) - { + if (verbose) { System.out.println("Retrieving document at '" + base + "'."); } - try - { + try { return readWSDL(base, is); - } - finally - { + } finally { this.loc.close(); this.loc = null; } diff --git a/src/main/java/com/ibm/wsdl/xml/WSDLWriterImpl.java b/src/main/java/com/ibm/wsdl/xml/WSDLWriterImpl.java index 9789190..8562101 100644 --- a/src/main/java/com/ibm/wsdl/xml/WSDLWriterImpl.java +++ b/src/main/java/com/ibm/wsdl/xml/WSDLWriterImpl.java @@ -20,109 +20,86 @@ import com.ibm.wsdl.util.xml.*; /** - * This class describes a collection of methods - * that allow a WSDL model to be written to a writer - * in an XML format that follows the WSDL schema. + * This class describes a collection of methods that allow a WSDL model to be written to a writer in an XML format that follows the WSDL schema. * * @author Matthew J. Duftler * @author Nirmal Mukhi */ -public class WSDLWriterImpl implements WSDLWriter -{ +public class WSDLWriterImpl implements WSDLWriter { /** * Sets the specified feature to the specified value. *
* There are no minimum features that must be supported. *
- * All feature names must be fully-qualified, Java package style. All
- * names starting with javax.wsdl. are reserved for features defined
- * by the JWSDL specification. It is recommended that implementation-
- * specific features be fully-qualified to match the package name
- * of that implementation. For example: com.abc.featureName
+ * All feature names must be fully-qualified, Java package style. All names starting with javax.wsdl. are reserved for features defined by the JWSDL specification. It is recommended that implementation- specific features be fully-qualified to match the package name of that implementation. For
+ * example: com.abc.featureName
*
- * @param name the name of the feature to be set.
- * @param value the value to set the feature to.
- * @throws IllegalArgumentException if the feature name is not recognized.
+ * @param name
+ * the name of the feature to be set.
+ * @param value
+ * the value to set the feature to.
+ * @throws IllegalArgumentException
+ * if the feature name is not recognized.
* @see #getFeature(String)
*/
- public void setFeature(String name, boolean value)
- throws IllegalArgumentException
- {
- if (name == null)
- {
+ public void setFeature(String name, boolean value) throws IllegalArgumentException {
+ if (name == null) {
throw new IllegalArgumentException("Feature name must not be null.");
- }
- else
- {
- throw new IllegalArgumentException("Feature name '" + name +
- "' not recognized.");
+ } else {
+ throw new IllegalArgumentException("Feature name '" + name + "' not recognized.");
}
}
/**
* Gets the value of the specified feature.
*
- * @param name the name of the feature to get the value of.
+ * @param name
+ * the name of the feature to get the value of.
* @return the value of the feature.
- * @throws IllegalArgumentException if the feature name is not recognized.
+ * @throws IllegalArgumentException
+ * if the feature name is not recognized.
* @see #setFeature(String, boolean)
*/
- public boolean getFeature(String name) throws IllegalArgumentException
- {
- if (name == null)
- {
+ public boolean getFeature(String name) throws IllegalArgumentException {
+ if (name == null) {
throw new IllegalArgumentException("Feature name must not be null.");
- }
- else
- {
- throw new IllegalArgumentException("Feature name '" + name +
- "' not recognized.");
+ } else {
+ throw new IllegalArgumentException("Feature name '" + name + "' not recognized.");
}
}
- protected void printDefinition(Definition def, PrintWriter pw)
- throws WSDLException
- {
- if (def == null)
- {
+ protected void printDefinition(Definition def, PrintWriter pw) throws WSDLException {
+ if (def == null) {
return;
}
- if (def.getPrefix(Constants.NS_URI_WSDL) == null)
- {
+ if (def.getPrefix(Constants.NS_URI_WSDL) == null) {
String prefix = "wsdl";
int subscript = 0;
- while (def.getNamespace(prefix) != null)
- {
+ while (def.getNamespace(prefix) != null) {
prefix = "wsdl" + subscript++;
}
def.addNamespace(prefix, Constants.NS_URI_WSDL);
}
- String tagName =
- DOMUtils.getQualifiedValue(Constants.NS_URI_WSDL,
- Constants.ELEM_DEFINITIONS,
- def);
+ String tagName = DOMUtils.getQualifiedValue(Constants.NS_URI_WSDL, Constants.ELEM_DEFINITIONS, def);
pw.print('<' + tagName);
QName name = def.getQName();
String targetNamespace = def.getTargetNamespace();
- Map namespaces = def.getNamespaces();
+ Map
- *
- *
+ *
+ *
+ *
+ *
* The steps in order are:
*
- * Once an instance of a WSDLFactory is obtained, invoke
- * newDefinition(), newWSDLReader(), or newWSDLWriter(), to create
- * the desired instances.
+ * Once an instance of a WSDLFactory is obtained, invoke newDefinition(), newWSDLReader(), or newWSDLWriter(), to create the desired instances.
*/
- public static WSDLFactory newInstance() throws WSDLException
- {
+ public static WSDLFactory newInstance() throws WSDLException {
String factoryImplName = findFactoryImplName();
return newInstance(factoryImplName);
}
/**
- * Get a new instance of a WSDLFactory. This method
- * returns an instance of the class factoryImplName.
- * Once an instance of a WSDLFactory is obtained, invoke
- * newDefinition(), newWSDLReader(), or newWSDLWriter(), to create
- * the desired instances.
+ * Get a new instance of a WSDLFactory. This method returns an instance of the class factoryImplName. Once an instance of a WSDLFactory is obtained, invoke newDefinition(), newWSDLReader(), or newWSDLWriter(), to create the desired instances.
*
- * @param factoryImplName the fully-qualified class name of the
- * class which provides a concrete implementation of the abstract
- * class WSDLFactory.
+ * @param factoryImplName
+ * the fully-qualified class name of the class which provides a concrete implementation of the abstract class WSDLFactory.
*/
- public static WSDLFactory newInstance(String factoryImplName)
- throws WSDLException
- {
- if (factoryImplName != null)
- {
- try
- {
- Class cl = Class.forName(factoryImplName);
-
- return (WSDLFactory)cl.newInstance();
- }
- catch (Exception e)
- {
+ public static WSDLFactory newInstance(String factoryImplName) throws WSDLException {
+ if (factoryImplName != null) {
+ try {
+ Class> cl = Class.forName(factoryImplName);
+
+ return (WSDLFactory) cl.getDeclaredConstructor().newInstance();
+ } catch (Exception e) {
/*
- Catches:
- ClassNotFoundException
- InstantiationException
- IllegalAccessException
- */
- throw new WSDLException(WSDLException.CONFIGURATION_ERROR,
- "Problem instantiating factory " +
- "implementation.",
- e);
+ * Catches: ClassNotFoundException InstantiationException IllegalAccessException
+ */
+ throw new WSDLException(WSDLException.CONFIGURATION_ERROR, "Problem instantiating factory implementation.", e);
}
- }
- else
- {
- throw new WSDLException(WSDLException.CONFIGURATION_ERROR,
- "Unable to find name of factory " +
- "implementation.");
+ } else {
+ throw new WSDLException(WSDLException.CONFIGURATION_ERROR, "Unable to find name of factory implementation.");
}
}
/**
- * Get a new instance of a WSDLFactory. This method
- * returns an instance of the class factoryImplName, using
- * the specified ClassLoader.
- * Once an instance of a WSDLFactory is obtained, invoke
- * newDefinition(), newWSDLReader(), or newWSDLWriter(), to create
- * the desired instances.
+ * Get a new instance of a WSDLFactory. This method returns an instance of the class factoryImplName, using the specified ClassLoader. Once an instance of a WSDLFactory is obtained, invoke newDefinition(), newWSDLReader(), or newWSDLWriter(), to create the desired instances.
*
- * @param factoryImplName the fully-qualified class name of the
- * class which provides a concrete implementation of the abstract
- * class WSDLFactory.
- * @param classLoader the ClassLoader to use to load the WSDLFactory
- * implementation.
+ * @param factoryImplName
+ * the fully-qualified class name of the class which provides a concrete implementation of the abstract class WSDLFactory.
+ * @param classLoader
+ * the ClassLoader to use to load the WSDLFactory implementation.
*/
- public static WSDLFactory newInstance(String factoryImplName,
- ClassLoader classLoader)
- throws WSDLException
- {
- if (factoryImplName != null)
- {
- try
- {
- Class cl = classLoader.loadClass(factoryImplName);
-
- return (WSDLFactory)cl.newInstance();
- }
- catch (Exception e)
- {
+ public static WSDLFactory newInstance(String factoryImplName, ClassLoader classLoader) throws WSDLException {
+ if (factoryImplName != null) {
+ try {
+ Class> cl = classLoader.loadClass(factoryImplName);
+
+ return (WSDLFactory) cl.getDeclaredConstructor().newInstance();
+ } catch (Exception e) {
/*
- Catches:
- ClassNotFoundException
- InstantiationException
- IllegalAccessException
- */
- throw new WSDLException(WSDLException.CONFIGURATION_ERROR,
- "Problem instantiating factory " +
- "implementation.",
- e);
+ * Catches: ClassNotFoundException InstantiationException IllegalAccessException
+ */
+ throw new WSDLException(WSDLException.CONFIGURATION_ERROR, "Problem instantiating factory " + "implementation.", e);
}
- }
- else
- {
- throw new WSDLException(WSDLException.CONFIGURATION_ERROR,
- "Unable to find name of factory " +
- "implementation.");
+ } else {
+ throw new WSDLException(WSDLException.CONFIGURATION_ERROR, "Unable to find name of factory " + "implementation.");
}
}
@@ -170,120 +111,86 @@ public static WSDLFactory newInstance(String factoryImplName,
public abstract WSDLWriter newWSDLWriter();
/**
- * Create a new instance of an ExtensionRegistry with pre-registered
- * serializers/deserializers for the SOAP, HTTP and MIME
- * extensions. Java extensionTypes are also mapped for all
- * the SOAP, HTTP and MIME extensions.
+ * Create a new instance of an ExtensionRegistry with pre-registered serializers/deserializers for the SOAP, HTTP and MIME extensions. Java extensionTypes are also mapped for all the SOAP, HTTP and MIME extensions.
*/
public abstract ExtensionRegistry newPopulatedExtensionRegistry();
- private static String findFactoryImplName()
- {
+ private static PrivilegedAction
- * The value of a QName contains a namespaceURI and a localPart.
- * The localPart provides the local part of the qualified name. The
- * namespaceURI is a URI reference identifying the namespace.
+ * The value of a QName contains a namespaceURI and a localPart. The localPart provides the local part of the qualified name. The namespaceURI is a URI reference identifying the namespace.
*
* Note: Some of this impl code was taken from Axis.
*
* @author axis-dev
* @author Matthew J. Duftler (duftler@us.ibm.com)
*/
-public class QName implements Serializable
-{
+public class QName implements Serializable {
// Comment/shared empty string.
- private static final String emptyString = "";
+ private static final String EMPTY_STRING = "";
// Field namespaceURI.
private String namespaceURI;
// Field localPart.
private String localPart;
-
+
// Field prefix.
private String prefix;
@@ -39,61 +34,51 @@ public class QName implements Serializable
/**
* Constructor for the QName.
*
- * @param localPart Local part of the QName
+ * @param localPart
+ * Local part of the QName
*/
- public QName(String localPart)
- {
- this.namespaceURI = emptyString;
- this.localPart = (localPart == null)
- ? emptyString
- : localPart.intern();
- this.prefix = emptyString;
+ public QName(String localPart) {
+ this.namespaceURI = EMPTY_STRING;
+ this.localPart = (localPart == null) ? EMPTY_STRING : localPart.intern();
+ this.prefix = EMPTY_STRING;
}
/**
* Constructor for the QName.
*
- * @param namespaceURI Namespace URI for the QName
- * @param localPart Local part of the QName.
+ * @param namespaceURI
+ * Namespace URI for the QName
+ * @param localPart
+ * Local part of the QName.
*/
- public QName(String namespaceURI, String localPart)
- {
- this.namespaceURI = (namespaceURI == null)
- ? emptyString
- : namespaceURI.intern();
- this.localPart = (localPart == null)
- ? emptyString
- : localPart.intern();
- this.prefix = emptyString;
+ public QName(String namespaceURI, String localPart) {
+ this.namespaceURI = (namespaceURI == null) ? EMPTY_STRING : namespaceURI.intern();
+ this.localPart = (localPart == null) ? EMPTY_STRING : localPart.intern();
+ this.prefix = EMPTY_STRING;
}
/**
* Constructor for the QName.
*
- * @param namespaceURI Namespace URI for the QName
- * @param localPart Local part of the QName.
- * @param prefix the xmlns-declared prefix for this namespaceURI
+ * @param namespaceURI
+ * Namespace URI for the QName
+ * @param localPart
+ * Local part of the QName.
+ * @param prefix
+ * the xmlns-declared prefix for this namespaceURI
*/
- public QName(String namespaceURI, String localPart, String prefix)
- {
- this.namespaceURI = (namespaceURI == null)
- ? emptyString
- : namespaceURI.intern();
- this.localPart = (localPart == null)
- ? emptyString
- : localPart.intern();
- this.prefix = (prefix == null)
- ? emptyString
- : prefix.intern();
+ public QName(String namespaceURI, String localPart, String prefix) {
+ this.namespaceURI = (namespaceURI == null) ? EMPTY_STRING : namespaceURI.intern();
+ this.localPart = (localPart == null) ? EMPTY_STRING : localPart.intern();
+ this.prefix = (prefix == null) ? EMPTY_STRING : prefix.intern();
}
-
+
/**
* Gets the Namespace URI for this QName
*
* @return Namespace URI
*/
- public String getNamespaceURI()
- {
+ public String getNamespaceURI() {
return namespaceURI;
}
@@ -102,19 +87,17 @@ public String getNamespaceURI()
*
* @return Local part
*/
- public String getLocalPart()
- {
+ public String getLocalPart() {
return localPart;
}
-
+
/**
* Gets the prefix for this QName
*
* @return prefix of this QName
*/
- public String getPrefix()
- {
- return prefix;
+ public String getPrefix() {
+ return prefix;
}
/**
@@ -122,126 +105,92 @@ public String getPrefix()
*
* @return a string representation of the QName
*/
- public String toString()
- {
- return ((namespaceURI == emptyString)
- ? localPart
- : '{' + namespaceURI + '}' + localPart);
+ public String toString() {
+ return (EMPTY_STRING.equals(namespaceURI) || namespaceURI == null ? localPart : '{' + namespaceURI + '}' + localPart);
}
/**
* Tests this QName for equality with another object.
*
- * If the given object is not a QName or is null then this method
- * returns false.
+ * If the given object is not a QName or is null then this method returns false.
*
- * For two QNames to be considered equal requires that both
- * localPart and namespaceURI must be equal. This method uses
- *
* This method satisfies the general contract of the
- * The string must be in the form returned by the QName.toString()
- * method, i.e. "{namespaceURI}localPart", with the "{namespaceURI}"
- * part being optional.
+ * The string must be in the form returned by the QName.toString() method, i.e. "{namespaceURI}localPart", with the "{namespaceURI}" part being optional.
*
- * This method doesn't do a full validation of the resulting QName.
- * In particular, it doesn't check that the resulting namespace URI
- * is a legal URI (per RFC 2396 and RFC 2732), nor that the resulting
- * local part is a legal NCName per the XML Namespaces specification.
+ * This method doesn't do a full validation of the resulting QName. In particular, it doesn't check that the resulting namespace URI is a legal URI (per RFC 2396 and RFC 2732), nor that the resulting local part is a legal NCName per the XML Namespaces specification.
*
- * @param s the string to be parsed
- * @throws IllegalArgumentException If the specified String
- * cannot be parsed as a QName
+ * @param s
+ * the string to be parsed
+ * @throws IllegalArgumentException
+ * If the specified String cannot be parsed as a QName
* @return QName corresponding to the given String
*/
- public static QName valueOf(String s)
- {
- if ((s == null) || s.equals(""))
- {
+ public static QName valueOf(String s) {
+ if ((s == null) || s.equals("")) {
throw new IllegalArgumentException("Invalid QName literal.");
}
- if (s.charAt(0) == '{')
- {
+ if (s.charAt(0) == '{') {
int i = s.indexOf('}');
- if (i == -1)
- {
+ if (i == -1) {
throw new IllegalArgumentException("Invalid QName literal.");
}
- if (i == s.length() - 1)
- {
+ if (i == s.length() - 1) {
throw new IllegalArgumentException("Invalid QName literal.");
- }
- else
- {
+ } else {
return new QName(s.substring(1, i), s.substring(i + 1));
}
- }
- else
- {
+ } else {
return new QName(s);
}
}
/**
- * Returns a hash code value for this QName object. The hash code
- * is based on both the localPart and namespaceURI parts of the
- * QName. This method satisfies the general contract of the
- * > importListIterator = imports.values().iterator();
+
+ while (importListIterator.hasNext()) {
+ List
- *
Usage:
- * java com.ibm.wsdl.xml.WSDLWriterImpl filename|URL
- * This test driver simply reads a WSDL document into a model
+ * A test driver.
*/
- public static void main(String[] argv) throws WSDLException
- {
- if (argv.length == 1)
- {
+ public static void main(String[] argv) throws WSDLException {
+ if (argv.length == 1) {
WSDLFactory wsdlFactory = WSDLFactory.newInstance();
- WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
- WSDLWriter wsdlWriter = wsdlFactory.newWSDLWriter();
+ WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
+ WSDLWriter wsdlWriter = wsdlFactory.newWSDLWriter();
wsdlWriter.writeWSDL(wsdlReader.readWSDL(null, argv[0]), System.out);
- }
- else
- {
+ } else {
System.err.println("Usage:");
System.err.println();
- System.err.println(" java " + WSDLWriterImpl.class.getName() +
- " filename|URL");
+ System.err.println(" java " + WSDLWriterImpl.class.getName() + " filename|URL");
System.err.println();
- System.err.println("This test driver simply reads a WSDL document " +
- "into a model (using a WSDLReader), and then " +
- "serializes it back to standard out. In effect, " +
- "it performs a round-trip test on the specified " +
- "WSDL document.");
+ System.err.println("This test driver simply reads a WSDL document into a model (using a WSDLReader), and then serializes it back to standard out. In effect, it performs a round-trip test on the specified " + "WSDL document.");
}
}
}
diff --git a/src/main/java/javax/wsdl/Binding.java b/src/main/java/javax/wsdl/Binding.java
index 34d787f..d075f7e 100644
--- a/src/main/java/javax/wsdl/Binding.java
+++ b/src/main/java/javax/wsdl/Binding.java
@@ -92,7 +92,7 @@ BindingOperation getBindingOperation(String name,
/**
* Get all the operation bindings defined here.
*/
- List getBindingOperations();
+ List
+ *
+ *
+ * Usage:
+ *
+ *
+ * java com.ibm.wsdl.xml.WSDLWriterImpl filename|URL
+ *
+ *
+ * This test driver simply reads a WSDL document into a model
* (using a WSDLReader), and then serializes it back to
* standard out. In effect, it performs a round-trip test on
- * the specified WSDL document.
+ * the specified WSDL document.
+ *
- *
* QName
class represents the value of a qualified name
- * as specified in XML
- * Schema Part2: Datatypes specification.
+ * QName
class represents the value of a qualified name as specified in XML Schema Part2: Datatypes specification.
* String.equals
to check equality of localPart
- * and namespaceURI. Any class that extends QName is required
- * to satisfy this equality contract.
+ * For two QNames to be considered equal requires that both localPart and namespaceURI must be equal. This method uses String.equals
to check equality of localPart and namespaceURI. Any class that extends QName is required to satisfy this equality contract.
* Object.equals
method.
*
- * @param obj the reference object with which to compare
+ * @param obj
+ * the reference object with which to compare
*
- * @return true
if the given object is identical to this
- * QName: false
otherwise.
+ * @return true
if the given object is identical to this QName: false
otherwise.
*/
- public final boolean equals(Object obj)
- {
- if (obj == this)
- {
+ public final boolean equals(Object obj) {
+ if (obj == this) {
return true;
}
- if (!(obj instanceof QName))
- {
+ if (!(obj instanceof QName)) {
return false;
}
- return (namespaceURI == ((QName) obj).namespaceURI)
- && (localPart == ((QName) obj).localPart);
+ return (namespaceURI == ((QName) obj).namespaceURI) && (localPart == ((QName) obj).localPart);
}
/**
* Returns a QName holding the value of the specified String.
* Object.hashCode
method.
+ * Returns a hash code value for this QName object. The hash code is based on both the localPart and namespaceURI parts of the QName. This method satisfies the general contract of the Object.hashCode
method.
*
* @return a hash code value for this Qname object
*/
- public final int hashCode()
- {
+ public final int hashCode() {
return namespaceURI.hashCode() ^ localPart.hashCode();
}
- private void readObject(ObjectInputStream in) throws IOException,
- ClassNotFoundException
- {
+ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
namespaceURI = namespaceURI.intern();
- localPart = localPart.intern();
- if(prefix == null)
- {
- //The serialized object did not have a 'prefix'.
- //i.e. it was serialized from an old version of QName.
- prefix = emptyString;
- }
- else
- {
- prefix = prefix.intern();
+ localPart = localPart.intern();
+ if (prefix == null) {
+ // The serialized object did not have a 'prefix'.
+ // i.e. it was serialized from an old version of QName.
+ prefix = EMPTY_STRING;
+ } else {
+ prefix = prefix.intern();
}
}
}
\ No newline at end of file