if (xrServiceStream == null) {
throw new WebServiceException(DBWSException.couldNotLocateFile(DBWS_SERVICE_XML));
}
DBWSModelProject xrServiceModelProject = new DBWSModelProject();
XMLContext xmlContext = new XMLContext(xrServiceModelProject);
XMLUnmarshaller unmarshaller = xmlContext.createUnmarshaller();
XRServiceModel xrServiceModel;
try {
xrServiceModel = (XRServiceModel)unmarshaller.unmarshal(xrServiceStream);
}
catch (XMLMarshalException e) {
// something went wrong parsing the eclipselink-dbws.xml - can't recover from that
throw new WebServiceException(DBWSException.couldNotParseDBWSFile());
}
try {
xrServiceStream.close();
}
catch (IOException ioe) {
/* safe to ignore */
}
String path = WSDL_DIR + DBWS_SCHEMA_XML;
if (sc != null) {
path = "WEB-INF/" + path;
xrSchemaStream = sc.getResourceAsStream(path);
}
else {
// if ServletContext is null, then we are running in JavaSE6 'container-less' mode
xrSchemaStream = parentClassLoader.getResourceAsStream(path);
}
if (xrSchemaStream == null) {
throw new WebServiceException(DBWSException.couldNotLocateFile(DBWS_SCHEMA_XML));
}
try {
buildService(xrServiceModel); // inherit xrService processing from XRServiceFactory
}
catch (Exception e) {
// something went wrong building the service
throw new WebServiceException(e);
}
// the xrService built by 'buildService' above is overridden to produce an
// instance of DBWSAdapter (a sub-class of XRService)
DBWSAdapter dbwsAdapter = (DBWSAdapter)xrService;
// get inline schema from WSDL - has additional types for the operations
StringWriter sw = new StringWriter();
InputStream wsdlInputStream = null;
path = WSDL_DIR + DBWS_WSDL;
if (sc != null) {
path = WEB_INF_DIR + path;
wsdlInputStream = sc.getResourceAsStream(path);
}
else {
// if ServletContext is null, then we are running in JavaSE6 'container-less' mode
wsdlInputStream = parentClassLoader.getResourceAsStream(path);
}
if (wsdlInputStream == null) {
throw new WebServiceException(DBWSException.couldNotLocateFile(DBWS_WSDL));
}
try {
StreamSource wsdlStreamSource = new StreamSource(wsdlInputStream);
Transformer t = TransformerFactory.newInstance().newTransformer(new StreamSource(
new StringReader(MATCH_SCHEMA)));
StreamResult streamResult = new StreamResult(sw);
t.transform(wsdlStreamSource, streamResult);
sw.toString();
wsdlInputStream.close();
SchemaModelProject schemaProject = new SchemaModelProject();
XMLContext xmlContext2 = new XMLContext(schemaProject);
unmarshaller = xmlContext2.createUnmarshaller();
Schema extendedSchema = (Schema)unmarshaller.unmarshal(new StringReader(sw.toString()));
dbwsAdapter.setExtendedSchema(extendedSchema);
}
catch (Exception e) {
// that's Ok, WSDL may not contain inline schema
}