com.sun.tools.internal.ws.resources.WsdlMessages Java Examples

The following examples show how to use com.sun.tools.internal.ws.resources.WsdlMessages. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WSDLParser.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public WSDLDocument parse() throws SAXException, IOException {
    // parse external binding files
    for (InputSource value : options.getWSDLBindings()) {
        errReceiver.pollAbort();
        Document root = forest.parse(value, false);
        if(root==null)       continue;   // error must have been reported
        Element binding = root.getDocumentElement();
        if (!Internalizer.fixNull(binding.getNamespaceURI()).equals(JAXWSBindingsConstants.NS_JAXWS_BINDINGS)
                || !binding.getLocalName().equals("bindings")){
                errReceiver.error(forest.locatorTable.getStartLocation(binding), WsdlMessages.PARSER_NOT_A_BINDING_FILE(
                    binding.getNamespaceURI(),
                    binding.getLocalName()));
            continue;
        }

        NodeList nl = binding.getElementsByTagNameNS(
            "http://java.sun.com/xml/ns/javaee", "handler-chains");
        for(int i = 0; i < nl.getLength(); i++){
            options.addHandlerChainConfiguration((Element) nl.item(i));
        }

    }
    return buildWSDLDocument();
}
 
Example #2
Source File: Internalizer.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private NodeList evaluateXPathMultiNode(Node bindings, Node target, String expression, NamespaceContext namespaceContext) {
    NodeList nlst;
    try {
        xpath.setNamespaceContext(namespaceContext);
        nlst = (NodeList) xpath.evaluate(expression, target, XPathConstants.NODESET);
    } catch (XPathExpressionException e) {
        reportError((Element) bindings, WsdlMessages.INTERNALIZER_X_PATH_EVALUATION_ERROR(e.getMessage()), e);
        return null; // abort processing this <jaxb:bindings>
    }

    if (nlst.getLength() == 0) {
        reportError((Element) bindings, WsdlMessages.INTERNALIZER_X_PATH_EVALUATES_TO_NO_TARGET(expression));
        return null; // abort
    }

    return nlst;
}
 
Example #3
Source File: Internalizer.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private NodeList evaluateXPathMultiNode(Node bindings, Node target, String expression, NamespaceContext namespaceContext) {
    NodeList nlst;
    try {
        xpath.setNamespaceContext(namespaceContext);
        nlst = (NodeList) xpath.evaluate(expression, target, XPathConstants.NODESET);
    } catch (XPathExpressionException e) {
        reportError((Element) bindings, WsdlMessages.INTERNALIZER_X_PATH_EVALUATION_ERROR(e.getMessage()), e);
        return null; // abort processing this <jaxb:bindings>
    }

    if (nlst.getLength() == 0) {
        reportError((Element) bindings, WsdlMessages.INTERNALIZER_X_PATH_EVALUATES_TO_NO_TARGET(expression));
        return null; // abort
    }

    return nlst;
}
 
Example #4
Source File: WSDLParser.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private void validateSchemaImports(Element typesElement){
        for (Iterator iter = XmlUtil.getAllChildren(typesElement); iter.hasNext();) {
            Element e = Util.nextElement(iter);
            if (e == null) {
                break;
            }
            if (XmlUtil.matchesTagNS(e, SchemaConstants.QNAME_IMPORT)) {
                errReceiver.warning(forest.locatorTable.getStartLocation(e), WsdlMessages.WARNING_WSI_R_2003());
            }else{
                checkNotWsdlElement(e);
//                if (XmlUtil.matchesTagNS(e, SchemaConstants.QNAME_SCHEMA)) {
//                    forest.getInlinedSchemaElement().add(e);
//                }

            }
        }
    }
 
Example #5
Source File: MetadataFinder.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private @Nullable Element getFromMetadataResolver(String systemId, Exception ex) {
    //try MEX
    MetaDataResolver resolver;
    ServiceDescriptor serviceDescriptor = null;
    for (MetadataResolverFactory resolverFactory : ServiceFinder.find(MetadataResolverFactory.class)) {
        resolver = resolverFactory.metadataResolver(options.entityResolver);
        try {
            serviceDescriptor = resolver.resolve(new URI(systemId));
            //we got the ServiceDescriptor, now break
            if (serviceDescriptor != null)
                break;
        } catch (URISyntaxException e) {
            throw new ParseException(e);
        }
    }

    if (serviceDescriptor != null) {
        errorReceiver.warning(new SAXParseException(WsdlMessages.TRY_WITH_MEX(ex.getMessage()), null, ex));
        return parseMetadata(systemId, serviceDescriptor);
    } else {
        errorReceiver.error(null, WsdlMessages.PARSING_UNABLE_TO_GET_METADATA(ex.getMessage(), WscompileMessages.WSIMPORT_NO_WSDL(systemId)), ex);
    }
    return null;
}
 
Example #6
Source File: TWSDLParserContextImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public QName translateQualifiedName(Locator locator, String s) {
    if (s == null)
        return null;

    String prefix = XmlUtil.getPrefix(s);
    String uri = null;

    if (prefix == null) {
        uri = getDefaultNamespaceURI();
    } else {
        uri = getNamespaceURI(prefix);
        if (uri == null) {
            errorReceiver.error(locator, WsdlMessages.PARSING_UNKNOWN_NAMESPACE_PREFIX(prefix));
        }
    }

    return new QName(uri, XmlUtil.getLocalPart(s));
}
 
Example #7
Source File: Internalizer.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private NodeList evaluateXPathMultiNode(Node bindings, Node target, String expression, NamespaceContext namespaceContext) {
    NodeList nlst;
    try {
        xpath.setNamespaceContext(namespaceContext);
        nlst = (NodeList) xpath.evaluate(expression, target, XPathConstants.NODESET);
    } catch (XPathExpressionException e) {
        reportError((Element) bindings, WsdlMessages.INTERNALIZER_X_PATH_EVALUATION_ERROR(e.getMessage()), e);
        return null; // abort processing this <jaxb:bindings>
    }

    if (nlst.getLength() == 0) {
        reportError((Element) bindings, WsdlMessages.INTERNALIZER_X_PATH_EVALUATES_TO_NO_TARGET(expression));
        return null; // abort
    }

    return nlst;
}
 
Example #8
Source File: Internalizer.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private NodeList evaluateXPathMultiNode(Node bindings, Node target, String expression, NamespaceContext namespaceContext) {
    NodeList nlst;
    try {
        xpath.setNamespaceContext(namespaceContext);
        nlst = (NodeList) xpath.evaluate(expression, target, XPathConstants.NODESET);
    } catch (XPathExpressionException e) {
        reportError((Element) bindings, WsdlMessages.INTERNALIZER_X_PATH_EVALUATION_ERROR(e.getMessage()), e);
        return null; // abort processing this <jaxb:bindings>
    }

    if (nlst.getLength() == 0) {
        reportError((Element) bindings, WsdlMessages.INTERNALIZER_X_PATH_EVALUATES_TO_NO_TARGET(expression));
        return null; // abort
    }

    return nlst;
}
 
Example #9
Source File: MetadataFinder.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private @Nullable Element getFromMetadataResolver(String systemId, Exception ex) {
    //try MEX
    MetaDataResolver resolver;
    ServiceDescriptor serviceDescriptor = null;
    for (MetadataResolverFactory resolverFactory : ServiceFinder.find(MetadataResolverFactory.class)) {
        resolver = resolverFactory.metadataResolver(options.entityResolver);
        try {
            serviceDescriptor = resolver.resolve(new URI(systemId));
            //we got the ServiceDescriptor, now break
            if (serviceDescriptor != null)
                break;
        } catch (URISyntaxException e) {
            throw new ParseException(e);
        }
    }

    if (serviceDescriptor != null) {
        errorReceiver.warning(new SAXParseException(WsdlMessages.TRY_WITH_MEX(ex.getMessage()), null, ex));
        return parseMetadata(systemId, serviceDescriptor);
    } else {
        errorReceiver.error(null, WsdlMessages.PARSING_UNABLE_TO_GET_METADATA(ex.getMessage(), WscompileMessages.WSIMPORT_NO_WSDL(systemId)), ex);
    }
    return null;
}
 
Example #10
Source File: TWSDLParserContextImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public QName translateQualifiedName(Locator locator, String s) {
    if (s == null)
        return null;

    String prefix = XmlUtil.getPrefix(s);
    String uri = null;

    if (prefix == null) {
        uri = getDefaultNamespaceURI();
    } else {
        uri = getNamespaceURI(prefix);
        if (uri == null) {
            errorReceiver.error(locator, WsdlMessages.PARSING_UNKNOWN_NAMESPACE_PREFIX(prefix));
        }
    }

    return new QName(uri, XmlUtil.getLocalPart(s));
}
 
Example #11
Source File: WSDLParser.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public WSDLDocument parse() throws SAXException, IOException {
    // parse external binding files
    for (InputSource value : options.getWSDLBindings()) {
        errReceiver.pollAbort();
        Document root = forest.parse(value, false);
        if(root==null)       continue;   // error must have been reported
        Element binding = root.getDocumentElement();
        if (!Internalizer.fixNull(binding.getNamespaceURI()).equals(JAXWSBindingsConstants.NS_JAXWS_BINDINGS)
                || !binding.getLocalName().equals("bindings")){
                errReceiver.error(forest.locatorTable.getStartLocation(binding), WsdlMessages.PARSER_NOT_A_BINDING_FILE(
                    binding.getNamespaceURI(),
                    binding.getLocalName()));
            continue;
        }

        NodeList nl = binding.getElementsByTagNameNS(
            "http://java.sun.com/xml/ns/javaee", "handler-chains");
        for(int i = 0; i < nl.getLength(); i++){
            options.addHandlerChainConfiguration((Element) nl.item(i));
        }

    }
    return buildWSDLDocument();
}
 
Example #12
Source File: Internalizer.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private NodeList evaluateXPathMultiNode(Node bindings, Node target, String expression, NamespaceContext namespaceContext) {
    NodeList nlst;
    try {
        xpath.setNamespaceContext(namespaceContext);
        nlst = (NodeList) xpath.evaluate(expression, target, XPathConstants.NODESET);
    } catch (XPathExpressionException e) {
        reportError((Element) bindings, WsdlMessages.INTERNALIZER_X_PATH_EVALUATION_ERROR(e.getMessage()), e);
        return null; // abort processing this <jaxb:bindings>
    }

    if (nlst.getLength() == 0) {
        reportError((Element) bindings, WsdlMessages.INTERNALIZER_X_PATH_EVALUATES_TO_NO_TARGET(expression));
        return null; // abort
    }

    return nlst;
}
 
Example #13
Source File: TWSDLParserContextImpl.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public QName translateQualifiedName(Locator locator, String s) {
    if (s == null)
        return null;

    String prefix = XmlUtil.getPrefix(s);
    String uri = null;

    if (prefix == null) {
        uri = getDefaultNamespaceURI();
    } else {
        uri = getNamespaceURI(prefix);
        if (uri == null) {
            errorReceiver.error(locator, WsdlMessages.PARSING_UNKNOWN_NAMESPACE_PREFIX(prefix));
        }
    }

    return new QName(uri, XmlUtil.getLocalPart(s));
}
 
Example #14
Source File: TWSDLParserContextImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public QName translateQualifiedName(Locator locator, String s) {
    if (s == null)
        return null;

    String prefix = XmlUtil.getPrefix(s);
    String uri = null;

    if (prefix == null) {
        uri = getDefaultNamespaceURI();
    } else {
        uri = getNamespaceURI(prefix);
        if (uri == null) {
            errorReceiver.error(locator, WsdlMessages.PARSING_UNKNOWN_NAMESPACE_PREFIX(prefix));
        }
    }

    return new QName(uri, XmlUtil.getLocalPart(s));
}
 
Example #15
Source File: WSDLParser.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #16
Source File: WSDLParser.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public WSDLDocument parse() throws SAXException, IOException {
    // parse external binding files
    for (InputSource value : options.getWSDLBindings()) {
        errReceiver.pollAbort();
        Document root = forest.parse(value, false);
        if(root==null)       continue;   // error must have been reported
        Element binding = root.getDocumentElement();
        if (!Internalizer.fixNull(binding.getNamespaceURI()).equals(JAXWSBindingsConstants.NS_JAXWS_BINDINGS)
                || !binding.getLocalName().equals("bindings")){
                errReceiver.error(forest.locatorTable.getStartLocation(binding), WsdlMessages.PARSER_NOT_A_BINDING_FILE(
                    binding.getNamespaceURI(),
                    binding.getLocalName()));
            continue;
        }

        NodeList nl = binding.getElementsByTagNameNS(
            "http://java.sun.com/xml/ns/javaee", "handler-chains");
        for(int i = 0; i < nl.getLength(); i++){
            options.addHandlerChainConfiguration((Element) nl.item(i));
        }

    }
    return buildWSDLDocument();
}
 
Example #17
Source File: WSDLParser.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #18
Source File: MemberSubmissionAddressingExtensionHandler.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean handleFaultExtension(TWSDLParserContext context, TWSDLExtensible parent, Element e) {
    if (extensionModeOn) {
        warn(context.getLocation(e));
        String actionValue = XmlUtil.getAttributeNSOrNull(e, WSA_ACTION_QNAME);
        if (actionValue == null || actionValue.equals("")) {
            errReceiver.warning(context.getLocation(e), WsdlMessages.WARNING_FAULT_EMPTY_ACTION(parent.getNameValue(), parent.getWSDLElementName().getLocalPart(), parent.getParent().getNameValue()));
            return false; // keep compiler happy
        }
        ((Fault) parent).setAction(actionValue);
        return true;
    } else {
        return fail(context.getLocation(e));
    }
}
 
Example #19
Source File: VersionChecker.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void startElement(String namespaceURI, String localName, String qName, Attributes atts)
    throws SAXException {

    super.startElement(namespaceURI, localName, qName, atts);

    if(!seenRoot) {
        // if this is the root element
        seenRoot = true;
        rootTagStart = new LocatorImpl(locator);

        version = atts.getValue(JAXWSBindingsConstants.NS_JAXWS_BINDINGS,"version");
        if( namespaceURI.equals(JAXWSBindingsConstants.NS_JAXWS_BINDINGS) ) {
            String version2 = atts.getValue("","version");
            if( version!=null && version2!=null ) {
                // we have both @version and @jaxb:version. error.
                SAXParseException e = new SAXParseException(
                    WsdlMessages.INTERNALIZER_TWO_VERSION_ATTRIBUTES(), locator);
                getErrorHandler().error(e);
            }
            //According to JAXWS 2.0 spec, if version attribute is missing its assumed to be "2.0"
            if( version==null)
                version = (version2!=null)?version2:"2.0";
        }

    }

    if( JAXWSBindingsConstants.NS_JAXWS_BINDINGS.equals(namespaceURI)){
        seenBindings = true;
        if(version == null)
            version = "2.0";
    }

}
 
Example #20
Source File: AbstractDocument.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public GloballyKnown find(Kind k, QName name) {
    Map map = getMap(k);
    Object result = map.get(name);
    if (result == null){
        errReceiver.error(null, WsdlMessages.ENTITY_NOT_FOUND_BY_Q_NAME(k.getName(), name, _systemId));
        throw new AbortException();
    }
    return (GloballyKnown) result;
}
 
Example #21
Source File: AbstractDocument.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void define(GloballyKnown e) {
    Map map = getMap(e.getKind());
    if (e.getName() == null)
        return;
    QName name =
        new QName(e.getDefining().getTargetNamespaceURI(), e.getName());

    if (map.containsKey(name)){
        errReceiver.error(e.getLocator(), WsdlMessages.ENTITY_DUPLICATE_WITH_TYPE(e.getElementName().getLocalPart(), e.getName()));
        throw new AbortException();
    }else{
        map.put(name, e);
    }
}
 
Example #22
Source File: WSDLParser.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private Import parseImport(
    TWSDLParserContextImpl context,
    Definitions definitions,
    Element e) {
    context.push();
    context.registerNamespaces(e);
    Import anImport = new Import(forest.locatorTable.getStartLocation(e));
    String namespace =
        Util.getRequiredAttribute(e, Constants.ATTR_NAMESPACE);
    anImport.setNamespace(namespace);
    String location = Util.getRequiredAttribute(e, Constants.ATTR_LOCATION);
    anImport.setLocation(location);

    // according to the schema in the WSDL 1.1 spec, an import can have a documentation element
    boolean gotDocumentation = 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(e), WsdlMessages.PARSING_ONLY_ONE_DOCUMENTATION_ALLOWED(e.getLocalName()));
            }
            gotDocumentation = true;
            anImport.setDocumentation(getDocumentationFor(e2));
        } else {
            errReceiver.error(forest.locatorTable.getStartLocation(e2), WsdlMessages.PARSING_INVALID_ELEMENT(e2.getTagName(),
                e2.getNamespaceURI()));
        }
    }
    context.pop();
    context.fireDoneParsingEntity(WSDLConstants.QNAME_IMPORT, anImport);
    return anImport;
}
 
Example #23
Source File: MemberSubmissionAddressingExtensionHandler.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean handleFaultExtension(TWSDLParserContext context, TWSDLExtensible parent, Element e) {
    if (extensionModeOn) {
        warn(context.getLocation(e));
        String actionValue = XmlUtil.getAttributeNSOrNull(e, WSA_ACTION_QNAME);
        if (actionValue == null || actionValue.equals("")) {
            errReceiver.warning(context.getLocation(e), WsdlMessages.WARNING_FAULT_EMPTY_ACTION(parent.getNameValue(), parent.getWSDLElementName().getLocalPart(), parent.getParent().getNameValue()));
            return false; // keep compiler happy
        }
        ((Fault) parent).setAction(actionValue);
        return true;
    } else {
        return fail(context.getLocation(e));
    }
}
 
Example #24
Source File: Port.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public Binding resolveBinding(AbstractDocument document) {
    try{
        return (Binding) document.find(Kinds.BINDING, _binding);
    } catch (NoSuchEntityException e) {
        errorReceiver.error(getLocator(), WsdlMessages.ENTITY_NOT_FOUND_BINDING(_binding, new QName(getNamespaceURI(), getName())));
        throw new AbortException();
    }
}
 
Example #25
Source File: Message.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void add(MessagePart part) {
    if (_partsByName.get(part.getName()) != null){
        errorReceiver.error(part.getLocator(), WsdlMessages.VALIDATION_DUPLICATE_PART_NAME(getName(), part.getName()));
        throw new AbortException();
    }

    if(part.getDescriptor() != null && part.getDescriptorKind() != null) {
        _partsByName.put(part.getName(), part);
        _parts.add(part);
    } else
        errorReceiver.warning(part.getLocator(), WsdlMessages.PARSING_ELEMENT_OR_TYPE_REQUIRED(part.getName()));
}
 
Example #26
Source File: WSDLParser.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private void checkNotWsdlRequired(Element e) {
    // check the wsdl:required attribute, fail if set to "true"
    String required =
        XmlUtil.getAttributeNSOrNull(
            e,
            Constants.ATTR_REQUIRED,
            Constants.NS_WSDL);
    if (required != null && required.equals(Constants.TRUE) && !options.isExtensionMode()) {
        errReceiver.error(forest.locatorTable.getStartLocation(e), WsdlMessages.PARSING_REQUIRED_EXTENSIBILITY_ELEMENT(e.getTagName(),
            e.getNamespaceURI()));
    }
}
 
Example #27
Source File: WSDLParser.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private void checkNotWsdlRequired(Element e) {
    // check the wsdl:required attribute, fail if set to "true"
    String required =
        XmlUtil.getAttributeNSOrNull(
            e,
            Constants.ATTR_REQUIRED,
            Constants.NS_WSDL);
    if (required != null && required.equals(Constants.TRUE) && !options.isExtensionMode()) {
        errReceiver.error(forest.locatorTable.getStartLocation(e), WsdlMessages.PARSING_REQUIRED_EXTENSIBILITY_ELEMENT(e.getTagName(),
            e.getNamespaceURI()));
    }
}
 
Example #28
Source File: Port.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public Binding resolveBinding(AbstractDocument document) {
    try{
        return (Binding) document.find(Kinds.BINDING, _binding);
    } catch (NoSuchEntityException e) {
        errorReceiver.error(getLocator(), WsdlMessages.ENTITY_NOT_FOUND_BINDING(_binding, new QName(getNamespaceURI(), getName())));
        throw new AbortException();
    }
}
 
Example #29
Source File: Binding.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public PortType resolvePortType(AbstractDocument document) {
    try {
        return (PortType) document.find(Kinds.PORT_TYPE, _portType);
    } catch (NoSuchEntityException e) {
        errorReceiver.error(getLocator(), WsdlMessages.ENTITY_NOT_FOUND_PORT_TYPE(_portType, new QName(getNamespaceURI(), getName())));
        throw new AbortException();
    }
}
 
Example #30
Source File: MetadataFinder.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Identifies WSDL documents from the {@link DOMForest}. Also identifies the root wsdl document.
 */
private void identifyRootWsdls(){
    for(String location: rootDocuments){
        Document doc = get(location);
        if(doc!=null){
            Element definition = doc.getDocumentElement();
            if(definition == null || definition.getLocalName() == null || definition.getNamespaceURI() == null)
                continue;
            if(definition.getNamespaceURI().equals(WSDLConstants.NS_WSDL) && definition.getLocalName().equals("definitions")){
                rootWsdls.add(location);
                //set the root wsdl at this point. Root wsdl is one which has wsdl:service in it
                NodeList nl = definition.getElementsByTagNameNS(WSDLConstants.NS_WSDL, "service");

                //TODO:what if there are more than one wsdl with wsdl:service element. Probably such cases
                //are rare and we will take any one of them, this logic should still work
                if(nl.getLength() > 0)
                    rootWSDL = location;
            }
        }
    }
    //no wsdl with wsdl:service found, throw error
    if(rootWSDL == null){
        StringBuilder strbuf = new StringBuilder();
        for(String str : rootWsdls){
            strbuf.append(str);
            strbuf.append('\n');
        }
        errorReceiver.error(null, WsdlMessages.FAILED_NOSERVICE(strbuf.toString()));
    }
}