001
014
015 package com.liferay.util.ant;
016
017 import java.io.File;
018
019 import org.apache.axis.tools.ant.wsdl.NamespaceMapping;
020 import org.apache.axis.tools.ant.wsdl.Wsdl2javaAntTask;
021
022
025 public class Wsdl2JavaTask {
026
027 public static void generateJava(String url, String output) {
028 generateJava(url, output, null);
029 }
030
031 public static void generateJava(String url, String output, String mapping) {
032 Wsdl2javaAntTask wsdl2Java = new Wsdl2javaAntTask();
033
034 if (mapping != null) {
035 NamespaceMapping namespaceMapping = new NamespaceMapping();
036
037 namespaceMapping.setFile(new File(mapping));
038
039 wsdl2Java.addMapping(namespaceMapping);
040 }
041
042 wsdl2Java.setFailOnNetworkErrors(true);
043 wsdl2Java.setOutput(new File(output));
044 wsdl2Java.setPrintStackTraceOnFailure(true);
045 wsdl2Java.setProject(AntUtil.getProject());
046 wsdl2Java.setServerSide(true);
047 wsdl2Java.setTestCase(false);
048 wsdl2Java.setURL(url);
049
050 try {
051 wsdl2Java.execute();
052 }
053 catch (Exception e) {
054 e.printStackTrace();
055 }
056 }
057
058 }