Search in sources :

Example 1 with NamespaceDeclaration

use of org.apache.woden.types.NamespaceDeclaration in project axis-axis2-java-core by apache.

the class WSDL20ToAxisServiceBuilder method createNamespaceMap.

/**
 * recursively drills down to get namespace pairs in nested imported elements
 *
 * @param descriptionElement - a description element from where import elements
 *                             and types can be found
 */
private void createNamespaceMap(DescriptionElement descriptionElement) {
    ImportElement[] importElements = descriptionElement.getImportElements();
    for (int i = 0; i < importElements.length; i++) {
        DescriptionElement descElem = importElements[i].getDescriptionElement();
        NamespaceDeclaration[] namespaceDeclarations = descElem.getDeclaredNamespaces();
        for (int j = 0; j < namespaceDeclarations.length; j++) {
            NamespaceDeclaration importedNamespaceDeclaration = namespaceDeclarations[j];
            if (!stringBasedNamespaceMap.containsKey(importedNamespaceDeclaration.getPrefix())) {
                stringBasedNamespaceMap.put(importedNamespaceDeclaration.getPrefix(), importedNamespaceDeclaration.getNamespaceURI().toString());
            }
        }
        // recursively drill down
        createNamespaceMap(descElem);
    }
}
Also used : ImportElement(org.apache.woden.wsdl20.xml.ImportElement) DescriptionElement(org.apache.woden.wsdl20.xml.DescriptionElement) Endpoint(org.apache.woden.wsdl20.Endpoint) NamespaceDeclaration(org.apache.woden.types.NamespaceDeclaration)

Example 2 with NamespaceDeclaration

use of org.apache.woden.types.NamespaceDeclaration in project axis-axis2-java-core by apache.

the class WSDL20ToAxisServiceBuilder method setup.

/**
 * contains all code which gathers non-wsdlService specific information from the
 * wsdl.
 * <p/>
 * After all the setup completes successfully, the setupComplete field is
 * set so that any subsequent calls to setup() will result in a no-op. Note
 * that subclass WSDL20ToAllAxisServicesBuilder will call populateService
 * for each endpoint in the WSDL. Separating the non-wsdlService specific
 * information here allows WSDL20ToAllAxisServicesBuilder to only do this
 * work 1 time per WSDL, instead of for each endpoint on each wsdlService.
 *
 * @throws AxisFault - Thrown in case the necessary resources are not available in the WSDL
 * @throws WSDLException - Thrown in case Woden throws an exception
 */
protected void setup() throws AxisFault, WSDLException {
    if (setupComplete) {
        // already setup, just do nothing and return
        return;
    }
    try {
        if (description == null) {
            Description description;
            DescriptionElement descriptionElement;
            if (wsdlURI != null && !"".equals(wsdlURI)) {
                description = readInTheWSDLFile(wsdlURI);
                descriptionElement = description.toElement();
            } else if (in != null) {
                description = readInTheWSDLFile(in);
                descriptionElement = description.toElement();
            } else {
                throw new AxisFault("No resources found to read the wsdl");
            }
            savedTargetNamespace = descriptionElement.getTargetNamespace().toString();
            namespacemap = descriptionElement.getDeclaredNamespaces();
            this.description = description;
        }
        // Create the namespacemap
        stringBasedNamespaceMap = new NamespaceMap();
        for (int i = 0; i < namespacemap.length; i++) {
            NamespaceDeclaration namespaceDeclaration = namespacemap[i];
            stringBasedNamespaceMap.put(namespaceDeclaration.getPrefix(), namespaceDeclaration.getNamespaceURI().toString());
        }
        DescriptionElement descriptionElement = description.toElement();
        createNamespaceMap(descriptionElement);
        setupComplete = true;
    } catch (AxisFault e) {
        // just rethrow AxisFaults
        throw e;
    } catch (WSDLException e) {
        // Preserve the WSDLException
        throw e;
    } catch (Exception e) {
        throw AxisFault.makeFault(e);
    }
}
Also used : AxisFault(org.apache.axis2.AxisFault) Description(org.apache.woden.wsdl20.Description) WSDLException(org.apache.woden.WSDLException) NamespaceMap(org.apache.ws.commons.schema.utils.NamespaceMap) DescriptionElement(org.apache.woden.wsdl20.xml.DescriptionElement) Endpoint(org.apache.woden.wsdl20.Endpoint) NamespaceDeclaration(org.apache.woden.types.NamespaceDeclaration) URISyntaxException(java.net.URISyntaxException) SAXException(org.xml.sax.SAXException) IOException(java.io.IOException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) WSDLException(org.apache.woden.WSDLException)

Aggregations

NamespaceDeclaration (org.apache.woden.types.NamespaceDeclaration)2 Endpoint (org.apache.woden.wsdl20.Endpoint)2 DescriptionElement (org.apache.woden.wsdl20.xml.DescriptionElement)2 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 AxisFault (org.apache.axis2.AxisFault)1 WSDLException (org.apache.woden.WSDLException)1 Description (org.apache.woden.wsdl20.Description)1 ImportElement (org.apache.woden.wsdl20.xml.ImportElement)1 NamespaceMap (org.apache.ws.commons.schema.utils.NamespaceMap)1 SAXException (org.xml.sax.SAXException)1