Message msg = new Message("GENERATE_TYPES_ERROR", LOG);
try {
wmodel.createJAXBContext();
} catch (Exception e) {
LOG.log(Level.SEVERE, "Create jaxbContext error");
throw new ToolException(msg, e);
}
SchemaOutputResolver resolver = new WSDLOutputResolver(env, wmodel);
try {
wmodel.getJaxbContext().generateSchema(resolver);
} catch (Exception e2) {
throw new ToolException(msg, e2);
}
Types types = definition.createTypes();
try {
Schema schema;
schema = (Schema)extensionRegistry.createExtension(Types.class,
new QName("http://www.w3.org/2001/XMLSchema",
"schema"));
DocumentBuilder docBuilder;
docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc = docBuilder.newDocument();
Element element = doc.createElement("xsd:schema");
Map<String, String> schemafileMap = wmodel.getSchemaNSFileMap();
Set<Map.Entry<String, String>> entryset = schemafileMap.entrySet();
Iterator<Map.Entry<String, String>> ite = entryset.iterator();
while (ite.hasNext()) {
Map.Entry<String, String> entry = (Map.Entry<String, String>)ite.next();
Element importelement = doc.createElement("xsd:import");
importelement.setAttribute("namespace", entry.getKey());
importelement.setAttribute("schemaLocation", entry.getValue());
element.appendChild(importelement);
}
schema.setElement(element);
types.addExtensibilityElement(schema);
definition.setTypes(types);
} catch (Exception e) {
throw new ToolException(msg, e);
}
definition.setTargetNamespace(wmodel.getTargetNameSpace());
definition.addNamespace(WSDLConstants.WSDL_PREFIX, WSDLConstants.NS_WSDL);