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");
}
}
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);
}
}
}
}
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);
}
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());
}
}
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;
}
Aggregations