Search in sources :

Example 6 with WSDLParser

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

the class WSDLParserTest method testParseUsingPolicyRequired.

public void testParseUsingPolicyRequired() throws Exception {
    final ErrorReceiverFilter errorReceiver = createErrorReceiver();
    final InputSource source = getResourceSource("usingpolicy-required.wsdl");
    final WsimportOptions options = new WsimportOptions();
    options.addWSDL(source);
    final WSDLParser instance = new WSDLParser(options, errorReceiver, null);
    final WSDLDocument wsdl = instance.parse();
    assertNotNull(wsdl);
    assertFalse(errorReceiver.hadError());
}
Also used : WSDLDocument(com.sun.tools.ws.wsdl.document.WSDLDocument) InputSource(org.xml.sax.InputSource) ErrorReceiverFilter(com.sun.tools.ws.wscompile.ErrorReceiverFilter) WsimportOptions(com.sun.tools.ws.wscompile.WsimportOptions) WSDLParser(com.sun.tools.ws.wsdl.parser.WSDLParser)

Example 7 with WSDLParser

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

the class WSDLParserTest method testParseSimple.

public void testParseSimple() throws Exception {
    final ErrorReceiverFilter errorReceiver = createErrorReceiver();
    final InputSource source = getResourceSource("simple.wsdl");
    final WsimportOptions options = new WsimportOptions();
    options.addWSDL(source);
    final WSDLParser instance = new WSDLParser(options, errorReceiver, null);
    final WSDLDocument wsdl = instance.parse();
    assertNotNull(wsdl);
    assertFalse(errorReceiver.hadError());
}
Also used : WSDLDocument(com.sun.tools.ws.wsdl.document.WSDLDocument) InputSource(org.xml.sax.InputSource) ErrorReceiverFilter(com.sun.tools.ws.wscompile.ErrorReceiverFilter) WsimportOptions(com.sun.tools.ws.wscompile.WsimportOptions) WSDLParser(com.sun.tools.ws.wsdl.parser.WSDLParser)

Example 8 with WSDLParser

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

the class WSDLParserTest method testParseUsingPolicy.

public void testParseUsingPolicy() throws Exception {
    final ErrorReceiverFilter errorReceiver = createErrorReceiver();
    final InputSource source = getResourceSource("usingpolicy.wsdl");
    final WsimportOptions options = new WsimportOptions();
    options.addWSDL(source);
    final WSDLParser instance = new WSDLParser(options, errorReceiver, null);
    final WSDLDocument wsdl = instance.parse();
    assertNotNull(wsdl);
    assertFalse(errorReceiver.hadError());
}
Also used : WSDLDocument(com.sun.tools.ws.wsdl.document.WSDLDocument) InputSource(org.xml.sax.InputSource) ErrorReceiverFilter(com.sun.tools.ws.wscompile.ErrorReceiverFilter) WsimportOptions(com.sun.tools.ws.wscompile.WsimportOptions) WSDLParser(com.sun.tools.ws.wsdl.parser.WSDLParser)

Example 9 with WSDLParser

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

the class WSDLModeler method buildModel.

@Override
public Model buildModel() {
    try {
        parser = new WSDLParser(options, errReceiver, forest);
        parser.addParserListener(new ParserListener() {

            @Override
            public void ignoringExtension(Entity entity, QName name, QName parent) {
                if (parent.equals(WSDLConstants.QNAME_TYPES)) {
                    // check for a schema element with the wrong namespace URI
                    if (name.getLocalPart().equals("schema") && !name.getNamespaceURI().equals("")) {
                        warning(entity, ModelerMessages.WSDLMODELER_WARNING_IGNORING_UNRECOGNIZED_SCHEMA_EXTENSION(name.getNamespaceURI()));
                    }
                }
            }

            @Override
            public void doneParsingEntity(QName element, Entity entity) {
            }
        });
        document = parser.parse();
        if (document == null || document.getDefinitions() == null) {
            return null;
        }
        document.validateLocally();
        Model model = internalBuildModel(document);
        if (model == null || errReceiver.hadError()) {
            return null;
        }
        // ClassNameCollector classNameCollector = new ClassNameCollector();
        classNameCollector.process(model);
        if (classNameCollector.getConflictingClassNames().isEmpty()) {
            if (errReceiver.hadError()) {
                return null;
            }
            return model;
        }
        // do another pass, this time with conflict resolution enabled
        model = internalBuildModel(document);
        classNameCollector.process(model);
        if (classNameCollector.getConflictingClassNames().isEmpty()) {
            // we're done
            if (errReceiver.hadError()) {
                return null;
            }
            return model;
        }
        // give up
        StringBuilder conflictList = new StringBuilder();
        boolean first = true;
        for (Iterator iter = classNameCollector.getConflictingClassNames().iterator(); iter.hasNext(); ) {
            if (!first) {
                conflictList.append(", ");
            } else {
                first = false;
            }
            conflictList.append((String) iter.next());
        }
        error(document.getDefinitions(), ModelerMessages.WSDLMODELER_UNSOLVABLE_NAMING_CONFLICTS(conflictList.toString()));
    } catch (ModelException e) {
        reportError(document.getDefinitions(), e.getMessage(), e);
    } catch (ParseException | IOException | SAXException e) {
        errReceiver.error(e);
    } catch (ValidationException e) {
        errReceiver.error(e.getMessage(), e);
    }
    // should never reach here
    return null;
}
Also used : QName(javax.xml.namespace.QName) IOException(java.io.IOException) SAXException(org.xml.sax.SAXException) S2JJAXBModel(com.sun.tools.xjc.api.S2JJAXBModel) SAXParseException(org.xml.sax.SAXParseException) WSDLParser(com.sun.tools.ws.wsdl.parser.WSDLParser)

Aggregations

WSDLParser (com.sun.tools.ws.wsdl.parser.WSDLParser)9 ErrorReceiverFilter (com.sun.tools.ws.wscompile.ErrorReceiverFilter)7 WsimportOptions (com.sun.tools.ws.wscompile.WsimportOptions)7 WSDLDocument (com.sun.tools.ws.wsdl.document.WSDLDocument)7 InputSource (org.xml.sax.InputSource)7 S2JJAXBModel (com.sun.tools.xjc.api.S2JJAXBModel)1 IOException (java.io.IOException)1 QName (javax.xml.namespace.QName)1 SAXException (org.xml.sax.SAXException)1 SAXParseException (org.xml.sax.SAXParseException)1