// If wsdl file is an http URL, download that WSDL and all embedded relative wsdls, schemas
if (ws.getWsdlFileUri().startsWith("http")) {
try {
downloadWsdlsAndSchemas(ws, new URL(ws.getWsdlFileUri()), wsdlDir);
} catch(Exception e) {
throw new IASDeploymentException(e.toString(), e);
}
wsdlFileUri = ws.getWsdlFileUri().substring(ws.getWsdlFileUri().lastIndexOf("/")+1);
wsdlFile = new File(wsdlDir, wsdlFileUri);
// at this point, we don't care we got it from and it simplifies
// the rest of the deployment process to just think that is was
// generated during deployment
// ws.setWsdlFileUri(null);
} else {
wsdlFileUri = ws.getWsdlFileUri();
if(wsdlFileUri.startsWith("/")) {
wsdlFile = new File(wsdlFileUri);
} else {
wsdlFile = new File(moduleDir, wsdlFileUri);
}
if (!wsdlFile.exists()) {
throw new IASDeploymentException("WebService " + ws.getName() + " wsdl file "
+ ws.getWsdlFileUri() + " not found in archive "
+ bundle.getModuleDescriptor().getArchiveUri());
}
}
} else {
//make required dirs in case they are not present
wsdlFileUri = JAXBRIContext.mangleNameToClassName(ws.getName()) + ".wsdl";
wsdlDir.mkdirs();
wsdlFile = new File(wsdlDir, wsdlFileUri);
}
for (WebServiceEndpoint endpoint : ws.getEndpoints()) {
String implClassName;
boolean jaxwsEndPtFound = false;
boolean jaxrpcEndPtFound = false;
if (endpoint.implementedByEjbComponent()) {
implClassName = endpoint.getEjbComponentImpl().getEjbClassName();
} else {
implClassName = endpoint.getWebComponentImpl().getWebComponentImplementation();
}
// check this is NOT a provider interface
Class implClass;
try {
implClass = app.getClassLoader().loadClass(implClassName);
} catch(Exception e) {
throw new IASDeploymentException("WebService " + ws.getName() + "implementation "
+ implClassName + " not found in archive "
+ bundle.getModuleDescriptor().getArchiveUri());
}
if (implClass!=null) {
if(implClass.getAnnotation(javax.xml.ws.WebServiceProvider.class) != null) {
// if we already found a jaxrpcendpoint, flag error since we do not support jaxws+jaxrpc endpoint
// in the same service
if(jaxrpcEndPtFound) {
throw new IASDeploymentException("WebService " + ws.getName() +
"has a JAXWS and a JAXRPC endpoint; this is not supported now");
}
//This is a JAXWS endpoint with @WebServiceProvider
//Do not run wsgen for this endpoint
jaxwsEndPtFound = true;
continue;
}
if(implClass.getAnnotation(javax.jws.WebService.class) != null) {
// if we already found a jaxrpcendpoint, flag error since we do not support jaxws+jaxrpc endpoint
// in the same service
if(jaxrpcEndPtFound) {
throw new IASDeploymentException("WebService " + ws.getName() +
"has a JAXWS and a JAXRPC endpoint; this is not supported now");
}
// This is a JAXWS endpoint with @WebService; Invoke wsgen
jaxwsEndPtFound = true;
String wsgenClassPath = getWsgenClassPath(classesDir, webinfLibDir,
request.getDeployedDirectory().getAbsolutePath()+File.separator+app.getLibraryDirectory(),
moduleDir.getAbsolutePath(),app);
boolean wsgenDone =
runWsGen(implClassName, wsdlFile.exists(), wsgenClassPath,
stubsDir, wsdlDir, endpoint.getServiceName(), endpoint.getWsdlPort());
if(!wsgenDone) {
// wsgen failed; if WSDL file were present, just throw a warning
// assuming that the user would have packaged everything
if(!wsdlFile.exists()) {
throw new IASDeploymentException("WSGEN FAILED");
} else {
logger.log(Level.WARNING,
"wsgen failed - proceeding under the assumption that the user packaged all required objects properly");
}
}
try {
endpoint.getWebService().setWsdlFileUrl(wsdlFile.toURI().toURL());
} catch(java.net.MalformedURLException mue) {
throw new IASDeploymentException("WSGEN Failed");
}
logger.log(Level.INFO, "wsgen successful");
} else {
// this is a jaxrpc endpoint
// if we already found a jaxws endpoint, flag error since we do not support jaxws+jaxrpc endpoint
// in the same service
if(jaxwsEndPtFound) {
throw new IASDeploymentException("WebService " + ws.getName() +
"has a JAXWS and a JAXRPC endpoint; this is not supported now");
}
// Set spec version to 1.1 to indicate later the wscompile should be run
// We do this here so that jaxrpc endpoint having J2EE1.4 or JavaEE5
// descriptors will work properly