Search in sources :

Example 16 with SchemaInfo

use of org.apache.cxf.service.model.SchemaInfo in project cxf by apache.

the class AttributeTest method setupClientAndRhino.

private void setupClientAndRhino(String clientProxyFactoryBeanId) throws IOException {
    testUtilities.setBus(getBean(Bus.class, "cxf"));
    testUtilities.initializeRhino();
    testUtilities.readResourceIntoRhino("/org/apache/cxf/javascript/cxf-utils.js");
    clientProxyFactory = getBean(JaxWsProxyFactoryBean.class, clientProxyFactoryBeanId);
    client = clientProxyFactory.getClientFactoryBean().create();
    serviceInfos = client.getEndpoint().getService().getServiceInfos();
    // there can only be one.
    assertEquals(1, serviceInfos.size());
    ServiceInfo serviceInfo = serviceInfos.get(0);
    schemata = serviceInfo.getSchemas();
    nameManager = BasicNameManager.newNameManager(serviceInfo);
    NamespacePrefixAccumulator prefixAccumulator = new NamespacePrefixAccumulator(serviceInfo.getXmlSchemaCollection());
    for (SchemaInfo schema : schemata) {
        SchemaJavascriptBuilder builder = new SchemaJavascriptBuilder(serviceInfo.getXmlSchemaCollection(), prefixAccumulator, nameManager);
        String allThatJavascript = builder.generateCodeForSchema(schema.getSchema());
        assertNotNull(allThatJavascript);
        testUtilities.readStringIntoRhino(allThatJavascript, schema.toString() + ".js");
    }
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) Bus(org.apache.cxf.Bus) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) NamespacePrefixAccumulator(org.apache.cxf.javascript.NamespacePrefixAccumulator) SchemaInfo(org.apache.cxf.service.model.SchemaInfo)

Example 17 with SchemaInfo

use of org.apache.cxf.service.model.SchemaInfo in project cxf by apache.

the class JAXBDataBinding method addSchemasForServiceInfos.

private void addSchemasForServiceInfos(OASISCatalogManager catalog, List<ServiceInfo> serviceList, Options opts, SchemaCompiler schemaCompiler, SchemaCollection schemaCollection) {
    Set<String> ids = new HashSet<>();
    for (ServiceInfo si : serviceList) {
        for (SchemaInfo sci : si.getSchemas()) {
            String key = sci.getSystemId();
            if (ids.contains(key)) {
                continue;
            }
            ids.add(key);
            Element ele = sci.getElement();
            if (context.fullValidateWSDL()) {
                validateSchema(ele, sci.getSystemId(), catalog, schemaCollection);
            }
            ele = removeImportElement(ele, key, catalog);
            InputSource is = new InputSource((InputStream) null);
            // key = key.replaceFirst("#types[0-9]+$", "");
            is.setSystemId(key);
            is.setPublicId(key);
            opts.addGrammar(is);
            try {
                XMLStreamReader reader = createNoCDATAReader(StaxUtils.createXMLStreamReader(ele, key));
                schemaCompiler.parseSchema(key, reader);
            } catch (XMLStreamException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) InputSource(org.xml.sax.InputSource) XMLStreamReader(javax.xml.stream.XMLStreamReader) XMLStreamException(javax.xml.stream.XMLStreamException) Element(org.w3c.dom.Element) HashSet(java.util.HashSet) SchemaInfo(org.apache.cxf.service.model.SchemaInfo)

Example 18 with SchemaInfo

use of org.apache.cxf.service.model.SchemaInfo in project cxf by apache.

the class WSDLRefValidator method getSchemas.

private void getSchemas(Bus bus) {
    Map<String, Element> schemaList = new HashMap<>();
    SchemaUtil schemaUtil = new SchemaUtil(bus, schemaList);
    List<SchemaInfo> si = new ArrayList<>();
    schemaUtil.getSchemas(definition, schemaCollection, si);
    ServiceSchemaInfo ssi = new ServiceSchemaInfo();
    ssi.setSchemaCollection(schemaCollection);
    ssi.setSchemaInfoList(si);
    ssi.setSchemaElementList(schemaList);
    bus.getExtension(WSDLManager.class).putSchemasForDefinition(definition, ssi);
}
Also used : HashMap(java.util.HashMap) SchemaUtil(org.apache.cxf.wsdl11.SchemaUtil) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) WSDLManager(org.apache.cxf.wsdl.WSDLManager) ServiceSchemaInfo(org.apache.cxf.service.model.ServiceSchemaInfo) SchemaInfo(org.apache.cxf.service.model.SchemaInfo) ServiceSchemaInfo(org.apache.cxf.service.model.ServiceSchemaInfo)

Example 19 with SchemaInfo

use of org.apache.cxf.service.model.SchemaInfo in project cxf by apache.

the class SourceGenerator method addSchemas.

private void addSchemas(List<SchemaInfo> schemas, SchemaCompiler compiler) {
    // handle package customizations first
    for (int i = 0; i < schemaPackageFiles.size(); i++) {
        compiler.parseSchema(schemaPackageFiles.get(i));
    }
    for (int i = 0; i < schemas.size(); i++) {
        SchemaInfo schema = schemas.get(i);
        String key = schema.getSystemId();
        if (key != null) {
            // when addressing the issue of retrieving WADLs with included schemas
            if (key.startsWith("classpath:")) {
                String resource = key.substring(10);
                URL url = ResourceUtils.getClasspathResourceURL(resource, SourceGenerator.class, bus);
                if (url != null) {
                    try {
                        key = url.toURI().toString();
                    } catch (Exception ex) {
                    // won't happen
                    }
                }
            }
        } else {
            key = Integer.toString(i);
        }
        InputSource is = new InputSource((InputStream) null);
        is.setSystemId(key);
        is.setPublicId(key);
        compiler.getOptions().addGrammar(is);
        compiler.parseSchema(key, schema.getElement());
    }
}
Also used : InputSource(org.xml.sax.InputSource) URL(java.net.URL) FileNotFoundException(java.io.FileNotFoundException) SAXException(org.xml.sax.SAXException) IOException(java.io.IOException) SAXParseException(org.xml.sax.SAXParseException) SchemaInfo(org.apache.cxf.service.model.SchemaInfo)

Example 20 with SchemaInfo

use of org.apache.cxf.service.model.SchemaInfo in project cxf by apache.

the class SourceGenerator method createSchemaInfo.

private SchemaInfo createSchemaInfo(Element schemaEl, String systemId) {
    SchemaInfo info = new SchemaInfo(schemaEl.getAttribute("targetNamespace"));
    info.setElement(schemaEl);
    info.setSystemId(systemId);
    // eviction of the DOM element from the memory
    try {
        XmlSchema xmlSchema = schemaCollection.read(schemaEl, systemId);
        info.setSchema(xmlSchema);
    } catch (Exception ex) {
    // may be due to unsupported resolvers for protocols like
    // classpath: or not the valid schema definition, may not be critical
    // for the purpose of the schema compilation.
    }
    return info;
}
Also used : XmlSchema(org.apache.ws.commons.schema.XmlSchema) FileNotFoundException(java.io.FileNotFoundException) SAXException(org.xml.sax.SAXException) IOException(java.io.IOException) SAXParseException(org.xml.sax.SAXParseException) SchemaInfo(org.apache.cxf.service.model.SchemaInfo)

Aggregations

SchemaInfo (org.apache.cxf.service.model.SchemaInfo)42 XmlSchema (org.apache.ws.commons.schema.XmlSchema)17 QName (javax.xml.namespace.QName)11 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)11 Element (org.w3c.dom.Element)10 XmlSchemaElement (org.apache.ws.commons.schema.XmlSchemaElement)9 IOException (java.io.IOException)8 HashMap (java.util.HashMap)7 XMLStreamException (javax.xml.stream.XMLStreamException)7 Message (org.apache.cxf.common.i18n.Message)6 FileNotFoundException (java.io.FileNotFoundException)5 URL (java.net.URL)5 MessagePartInfo (org.apache.cxf.service.model.MessagePartInfo)5 InputSource (org.xml.sax.InputSource)5 SAXException (org.xml.sax.SAXException)5 SAXParseException (org.xml.sax.SAXParseException)5 File (java.io.File)4 Method (java.lang.reflect.Method)4 HashSet (java.util.HashSet)4 SchemaCollection (org.apache.cxf.common.xmlschema.SchemaCollection)4