public void handleWSDLToJavaGeneration(Configuration config, String outDir)
{
WSDLToJavaConfig w2jc = config.getWSDLToJavaConfig(false);
GlobalConfig glc = config.getGlobalConfig(false);
WSDLToJava wsdlToJava = new WSDLToJava();
wsdlToJava.setTypeMapping(new LiteralTypeMapping());
wsdlToJava.setGenerateSerializableTypes(w2jc.serializableTypes);
WSDLDefinitions wsdl = null;
try
{
URL wsdlURL = null;
try
{
wsdlURL = new URL(w2jc.wsdlLocation);
}
catch (MalformedURLException e)
{
// ignore
}
if (wsdlURL == null)
{
File wsdlFile = new File(w2jc.wsdlLocation);
if (wsdlFile.exists())
{
wsdlURL = wsdlFile.toURL();
}
}
if (wsdlURL == null)
{
ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
wsdlURL = ctxLoader.getResource(w2jc.wsdlLocation);
}
if (wsdlURL == null)
throw new IllegalArgumentException("Cannot load wsdl: " + w2jc.wsdlLocation);
wsdl = wsdlToJava.convertWSDL2Java(wsdlURL);
if (glc != null)
wsdlToJava.setNamespacePackageMap(glc.packageNamespaceMap);
wsdlToJava.setParameterStyle(w2jc.parameterStyle);
wsdlToJava.generateSEI(wsdl, new File(outDir));
//Generate the Service File
this.generateServiceFile(getPackageName(wsdl, glc), wsdl, outDir);
//Generate the Mapping File
if (w2jc.mappingFileNeeded)
{
MappingFileGenerator mgf = new MappingFileGenerator(wsdl, new LiteralTypeMapping());
if (glc != null && glc.packageNamespaceMap != null)
mgf.setNamespacePackageMap(glc.packageNamespaceMap);
mgf.setServiceName(wsdl.getServices()[0].getName().getLocalPart());
mgf.setParameterStyle(w2jc.parameterStyle);
JavaWsdlMapping jwm = mgf.generate();
Writer writer = IOUtils.getCharsetFileWriter(new File(outDir + "/" + w2jc.mappingFileName), Constants.DEFAULT_XML_CHARSET);
writer.write(Constants.XML_HEADER);
writer.write(DOMWriter.printNode(DOMUtils.parse(jwm.serialize()), true));
writer.close();
}
//Generate the webservices.xml file
if (w2jc.wsxmlFileNeeded)
{
String seiName = "mypackage.MyServiceEndpointInterface";
String serviceName = "MyServiceName";
if (wsdl.getServices().length == 1)
serviceName = wsdl.getServices()[0].getName().getLocalPart();
if (wsdl.getInterfaces().length == 1)
{
String seiPackage = getPackageName(wsdl, glc);
seiName = seiPackage + "." + wsdlToJava.getServiceEndpointInterfaceName(wsdl.getInterfaces()[0]);
}
WebservicesXMLCreator wscr = new WebservicesXMLCreatorImpl();
wscr.setTargetNamespace(wsdl.getTargetNamespace());
wscr.setSeiName(seiName);