Search in sources :

Example 1 with Definitions

use of com.sun.tools.ws.wsdl.document.Definitions in project metro-jax-ws by eclipse-ee4j.

the class WSDLParser method buildWSDLDocument.

private WSDLDocument buildWSDLDocument() {
    /*
          Currently we are working off first WSDL document
          TODO: add support of creating WSDLDocument from fromjava.collection of WSDL documents
         */
    String location = forest.getRootWSDL();
    // It means that WSDL is not found, an error might have been reported, lets try to recover
    if (location == null)
        return null;
    Document root = forest.get(location);
    if (root == null)
        return null;
    WSDLDocument document = new WSDLDocument(forest, errReceiver);
    document.setSystemId(location);
    TWSDLParserContextImpl context = new TWSDLParserContextImpl(forest, document, listeners, errReceiver);
    Definitions definitions = parseDefinitions(context, root);
    document.setDefinitions(definitions);
    return document;
}
Also used : WSDLDocument(com.sun.tools.ws.wsdl.document.WSDLDocument) TWSDLParserContextImpl(com.sun.tools.ws.wsdl.framework.TWSDLParserContextImpl) Definitions(com.sun.tools.ws.wsdl.document.Definitions) Document(org.w3c.dom.Document) WSDLDocument(com.sun.tools.ws.wsdl.document.WSDLDocument)

Example 2 with Definitions

use of com.sun.tools.ws.wsdl.document.Definitions in project metro-jax-ws by eclipse-ee4j.

the class JwsImplGenerator method getBindingType.

private String getBindingType(QName bName) {
    String value = null;
    // process the bindings in definitions of model.entity
    if (model.getEntity() instanceof Definitions) {
        Definitions definitions = (Definitions) model.getEntity();
        if (definitions != null) {
            Iterator bindings = definitions.bindings();
            if (bindings != null) {
                while (bindings.hasNext()) {
                    Binding binding = (Binding) bindings.next();
                    if (bName.getLocalPart().equals(binding.getName()) && bName.getNamespaceURI().equals(binding.getNamespaceURI())) {
                        List<TWSDLExtension> bindextends = (List<TWSDLExtension>) binding.extensions();
                        for (TWSDLExtension wsdlext : bindextends) {
                            value = resolveBindingValue(wsdlext);
                            if (value != null)
                                break;
                        }
                        break;
                    }
                }
            }
        }
    }
    // process the bindings in whole document
    if (value == null) {
        if (model.getEntity() instanceof Definitions) {
            Definitions definitions = (Definitions) model.getEntity();
            Binding b = (Binding) definitions.resolveBindings().get(bName);
            if (b != null) {
                List<TWSDLExtension> bindextends = (List<TWSDLExtension>) b.extensions();
                for (TWSDLExtension wsdlext : bindextends) {
                    value = resolveBindingValue(wsdlext);
                    if (value != null)
                        break;
                }
            }
        }
    }
    return value;
}
Also used : Binding(com.sun.tools.ws.wsdl.document.Binding) SOAPBinding(com.sun.tools.ws.wsdl.document.soap.SOAPBinding) SOAP12Binding(com.sun.tools.ws.wsdl.document.soap.SOAP12Binding) TWSDLExtension(com.sun.tools.ws.api.wsdl.TWSDLExtension) Definitions(com.sun.tools.ws.wsdl.document.Definitions) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List)

Example 3 with Definitions

use of com.sun.tools.ws.wsdl.document.Definitions in project metro-jax-ws by eclipse-ee4j.

the class WSDLParser method parseDefinitions.

private Definitions parseDefinitions(TWSDLParserContextImpl context, Document root) {
    context.pushWSDLLocation();
    context.setWSDLLocation(context.getDocument().getSystemId());
    new Internalizer(forest, options, errReceiver).transform();
    Definitions definitions = parseDefinitionsNoImport(context, root);
    if (definitions == null) {
        Locator locator = forest.locatorTable.getStartLocation(root.getDocumentElement());
        errReceiver.error(locator, WsdlMessages.PARSING_NOT_AWSDL(locator.getSystemId()));
    }
    processImports(context);
    context.popWSDLLocation();
    return definitions;
}
Also used : Locator(org.xml.sax.Locator) Definitions(com.sun.tools.ws.wsdl.document.Definitions)

Example 4 with Definitions

use of com.sun.tools.ws.wsdl.document.Definitions in project metro-jax-ws by eclipse-ee4j.

the class WSDLParser method parseDefinitionsNoImport.

private Definitions parseDefinitionsNoImport(TWSDLParserContextImpl context, Document doc) {
    Element e = doc.getDocumentElement();
    // at this poinjt we expect a wsdl or schema document to be fully qualified
    if (e.getNamespaceURI() == null || (!e.getNamespaceURI().equals(WSDLConstants.NS_WSDL) || !e.getLocalName().equals("definitions"))) {
        return null;
    }
    context.push();
    context.registerNamespaces(e);
    Definitions definitions = new Definitions(context.getDocument(), forest.locatorTable.getStartLocation(e));
    String name = XmlUtil.getAttributeOrNull(e, Constants.ATTR_NAME);
    definitions.setName(name);
    String targetNamespaceURI = XmlUtil.getAttributeOrNull(e, Constants.ATTR_TARGET_NAMESPACE);
    definitions.setTargetNamespaceURI(targetNamespaceURI);
    boolean gotDocumentation = false;
    boolean gotTypes = false;
    for (Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext(); ) {
        Element e2 = Util.nextElement(iter);
        if (e2 == null)
            break;
        if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_DOCUMENTATION)) {
            if (gotDocumentation) {
                errReceiver.error(forest.locatorTable.getStartLocation(e2), WsdlMessages.PARSING_ONLY_ONE_DOCUMENTATION_ALLOWED(e.getLocalName()));
                return null;
            }
            gotDocumentation = true;
            if (definitions.getDocumentation() == null)
                definitions.setDocumentation(getDocumentationFor(e2));
        } else if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_TYPES)) {
            if (gotTypes && !options.isExtensionMode()) {
                errReceiver.error(forest.locatorTable.getStartLocation(e2), WsdlMessages.PARSING_ONLY_ONE_TYPES_ALLOWED(Constants.TAG_DEFINITIONS));
                return null;
            }
            gotTypes = true;
            // that will be needed to create jaxb model
            if (!options.isExtensionMode())
                validateSchemaImports(e2);
        } else if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_MESSAGE)) {
            Message message = parseMessage(context, definitions, e2);
            definitions.add(message);
        } else if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_PORT_TYPE)) {
            PortType portType = parsePortType(context, definitions, e2);
            definitions.add(portType);
        } else if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_BINDING)) {
            Binding binding = parseBinding(context, definitions, e2);
            definitions.add(binding);
        } else if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_SERVICE)) {
            Service service = parseService(context, definitions, e2);
            definitions.add(service);
        } else if (XmlUtil.matchesTagNS(e2, WSDLConstants.QNAME_IMPORT)) {
            definitions.add(parseImport(context, definitions, e2));
        } else if (XmlUtil.matchesTagNS(e2, SchemaConstants.QNAME_IMPORT)) {
            errReceiver.warning(forest.locatorTable.getStartLocation(e2), WsdlMessages.WARNING_WSI_R_2003());
        } else {
            // possible extensibility element -- must live outside the WSDL namespace
            checkNotWsdlElement(e2);
            if (!handleExtension(context, definitions, e2)) {
                checkNotWsdlRequired(e2);
            }
        }
    }
    context.pop();
    context.fireDoneParsingEntity(WSDLConstants.QNAME_DEFINITIONS, definitions);
    return definitions;
}
Also used : Binding(com.sun.tools.ws.wsdl.document.Binding) Message(com.sun.tools.ws.wsdl.document.Message) Element(org.w3c.dom.Element) Definitions(com.sun.tools.ws.wsdl.document.Definitions) Iterator(java.util.Iterator) Service(com.sun.tools.ws.wsdl.document.Service) PortType(com.sun.tools.ws.wsdl.document.PortType)

Example 5 with Definitions

use of com.sun.tools.ws.wsdl.document.Definitions in project metro-jax-ws by eclipse-ee4j.

the class WSDLParser method processImports.

private void processImports(TWSDLParserContextImpl context) {
    for (String location : forest.getExternalReferences()) {
        if (!context.getDocument().isImportedDocument(location)) {
            Document doc = forest.get(location);
            if (doc == null)
                continue;
            Definitions importedDefinitions = parseDefinitionsNoImport(context, doc);
            if (importedDefinitions == null)
                continue;
            context.getDocument().addImportedEntity(importedDefinitions);
            context.getDocument().addImportedDocument(location);
        }
    }
}
Also used : Definitions(com.sun.tools.ws.wsdl.document.Definitions) Document(org.w3c.dom.Document) WSDLDocument(com.sun.tools.ws.wsdl.document.WSDLDocument)

Aggregations

Definitions (com.sun.tools.ws.wsdl.document.Definitions)5 Binding (com.sun.tools.ws.wsdl.document.Binding)2 WSDLDocument (com.sun.tools.ws.wsdl.document.WSDLDocument)2 Iterator (java.util.Iterator)2 Document (org.w3c.dom.Document)2 TWSDLExtension (com.sun.tools.ws.api.wsdl.TWSDLExtension)1 Message (com.sun.tools.ws.wsdl.document.Message)1 PortType (com.sun.tools.ws.wsdl.document.PortType)1 Service (com.sun.tools.ws.wsdl.document.Service)1 SOAP12Binding (com.sun.tools.ws.wsdl.document.soap.SOAP12Binding)1 SOAPBinding (com.sun.tools.ws.wsdl.document.soap.SOAPBinding)1 TWSDLParserContextImpl (com.sun.tools.ws.wsdl.framework.TWSDLParserContextImpl)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Element (org.w3c.dom.Element)1 Locator (org.xml.sax.Locator)1