throw new JAXBException(ex.getMessage());
}
}
private void attachSchema() throws Exception {
Types types = definition.createTypes();
Schema wsdlSchema = (Schema)
definition.getExtensionRegistry().createExtension(Types.class,
new QName(Constants.URI_2001_SCHEMA_XSD,
"schema"));
// See if a NamespaceMap has already been added to the schema (this can be the case with object
// references. If so, simply add the XSD URI to the map. Otherwise, create a new one.
NamespaceMap nsMap = null;
try {
nsMap = (NamespaceMap)schema.getNamespaceContext();
} catch (ClassCastException ex) {
// Consume. This will mean that the context has not been set.
}
if (nsMap == null) {
nsMap = new NamespaceMap();
nsMap.add("xs", Constants.URI_2001_SCHEMA_XSD);
schema.setNamespaceContext(nsMap);
} else {
nsMap.add("xs", Constants.URI_2001_SCHEMA_XSD);
}
org.w3c.dom.Element el = XmlSchemaSerializer.serializeSchema(schema, true)[0].getDocumentElement();
wsdlSchema.setElement(el);
types.addExtensibilityElement(wsdlSchema);
definition.setTypes(types);
}