Methods Summary |
---|
public void | addComplexType(ComplexType ct)Nested element for Complex Types.
Each Complex Type uses the following fields:
complexTypes.add(ct);
|
public void | addMapping(NamespaceMapping mapping)add a mapping of namespaces to packages
mappings.addMapping(mapping);
|
public void | addMappingSet(MappingSet mappingset)add a mapping of namespaces to packages
mappings.addMappingSet(mappingset);
|
public void | addSysproperty(Environment.Variable sysp)Adds a system property that tests can access.
commandline.addSysproperty(sysp);
|
public org.apache.tools.ant.types.Path | createClasspath()Set the optional classpath
if (classpath == null) {
classpath = new Path(getProject());
classpath = classpath.concatSystemClasspath();
}
return classpath.createPath();
|
public void | execute()execute the task
AntClassLoader cl = new AntClassLoader(getClass().getClassLoader(),
getProject(),
classpath == null ? createClasspath() : classpath,
false);
ClassUtils.setDefaultClassLoader(cl);
//add extra classes to the classpath when the classpath attr is not null
if (extraClasses != null) {
StringTokenizer tokenizer = new StringTokenizer(extraClasses, " ,");
while (tokenizer.hasMoreTokens()) {
String clsName = tokenizer.nextToken();
ClassUtils.setClassLoader(clsName, cl);
}
}
CommandlineJava.SysProperties sysProperties =
commandline.getSystemProperties();
if (sysProperties != null) {
sysProperties.setSystem();
}
try {
traceParams(Project.MSG_VERBOSE);
validate();
// Instantiate the emitter
Emitter emitter = new Emitter();
//do the mappings, packages are the key for this map
mappings.execute(this,namespaceMap, true);
if (!namespaceMap.isEmpty()) {
emitter.setNamespaceMap(namespaceMap);
}
if (servicePortName != null) {
emitter.setServicePortName(servicePortName);
}
if (portTypeName != null) {
emitter.setPortTypeName(portTypeName);
}
if (bindingName != null) {
emitter.setBindingName(bindingName);
}
log("Java2WSDL " + className, Project.MSG_INFO);
emitter.setCls(className);
if (implClass != null) {
emitter.setImplCls(implClass);
}
if (exclude != null) {
emitter.setDisallowedMethods(exclude);
}
if (stopClasses != null) {
emitter.setStopClasses(stopClasses);
}
if (extraClasses != null) {
emitter.setExtraClasses(extraClasses);
}
TypeMappingRegistryImpl tmr = new TypeMappingRegistryImpl();
tmr.doRegisterFromVersion(typeMappingVersion);
emitter.setTypeMappingRegistry(tmr);
// Create TypeMapping and register complex types
TypeMappingDelegate tmi = (TypeMappingDelegate)tmr.getDefaultTypeMapping();
Iterator i = complexTypes.iterator();
while (i.hasNext()) {
((ComplexType) i.next()).register(tmi);
}
if (style != null) {
emitter.setStyle(style);
}
if (use != null) {
emitter.setUse(use);
}
if (importSchema != null) {
emitter.setInputSchema(importSchema);
}
if (input != null) {
emitter.setInputWSDL(input);
}
emitter.setIntfNamespace(namespace);
emitter.setImplNamespace(namespaceImpl);
emitter.setLocationUrl(location);
emitter.setImportUrl(locationImport);
emitter.setUseInheritedMethods(useInheritedMethods);
if(serviceElementName!=null) {
emitter.setServiceElementName(serviceElementName);
}
if(methods!=null) {
emitter.setAllowedMethods(methods);
}
if (soapAction != null) {
emitter.setSoapAction(soapAction);
}
if (outputImpl == null) {
// Normal case
emitter.emit(output, Emitter.MODE_ALL);
} else {
// Emit interface and implementation wsdls
emitter.emit(output, outputImpl);
}
if (isDeploy == true) {
generateServerSide(emitter, (outputImpl != null) ? outputImpl : output);
}
} catch(BuildException b) {
//pass build exceptions up the wire
throw b;
} catch (Throwable t) {
//other trouble: stack trace the trouble and throw an exception
StringWriter writer = new StringWriter();
t.printStackTrace(new PrintWriter(writer));
log(writer.getBuffer().toString(), Project.MSG_ERR);
throw new BuildException("Error while running " + getClass().getName(), t);
} finally {
if (sysProperties != null) {
sysProperties.restoreSystem();
}
}
|
protected void | generateServerSide(org.apache.axis.wsdl.fromJava.Emitter j2w, java.lang.String wsdlFileName)Generate the server side artifacts from the generated WSDL
org.apache.axis.wsdl.toJava.Emitter w2j = new org.apache.axis.wsdl.toJava.Emitter();
File wsdlFile = new File(wsdlFileName);
w2j.setServiceDesc(j2w.getServiceDesc());
w2j.setQName2ClassMap(j2w.getQName2ClassMap());
w2j.setOutputDir(wsdlFile.getParent());
w2j.setServerSide(true);
w2j.setDeploy(true);
w2j.setHelperWanted(true);
// setup namespace-to-package mapping
String ns = j2w.getIntfNamespace();
String clsName = j2w.getCls().getName();
int idx = clsName.lastIndexOf(".");
String pkg = null;
if (idx > 0) {
pkg = clsName.substring(0, idx);
w2j.getNamespaceMap().put(ns, pkg);
}
Map nsmap = j2w.getNamespaceMap();
if (nsmap != null) {
for (Iterator i = nsmap.keySet().iterator(); i.hasNext(); ) {
pkg = (String) i.next();
ns = (String) nsmap.get(pkg);
w2j.getNamespaceMap().put(ns, pkg);
}
}
// set 'deploy' mode
w2j.setDeploy(true);
if (j2w.getImplCls() != null) {
w2j.setImplementationClassName(j2w.getImplCls().getName());
} else {
if (!j2w.getCls().isInterface()) {
w2j.setImplementationClassName(j2w.getCls().getName());
} else {
throw new Exception("implementation class is not specified.");
}
}
w2j.run(wsdlFileName);
|
public void | setBindingName(java.lang.String parameter)The name to use use for the binding element.
If not specified, the value of the
servicePortName + "SoapBinding" is used.
this.bindingName = parameter;
|
public void | setClassName(java.lang.String parameter)the class name to import, eg. org.example.Foo. Required.
The class must be on the classpath.
this.className = parameter;
|
public void | setClasspath(org.apache.tools.ant.types.Path classpath)Set the optional classpath
createClasspath().append(classpath);
|
public void | setClasspathRef(org.apache.tools.ant.types.Reference r)Set the reference to an optional classpath
createClasspath().setRefid(r);
|
public void | setDeploy(boolean deploy)Sets the deploy flag
this.isDeploy = deploy;
|
public void | setExclude(java.lang.String exclude)Comma separated list of methods to exclude from the wsdl file.
this.exclude = exclude;
|
public void | setExtraClasses(java.lang.String extraClasses)A comma separated list of classes to add to the classpath.
this.extraClasses = extraClasses;
|
public void | setImplClass(java.lang.String parameter)Sometimes extra information is available in the implementation class
file. Use this option to specify the implementation class.
this.implClass = parameter;
|
public void | setImportSchema(java.io.File parameter)Option attribute that indicates the name of an XML Schema file that
should be physically imported into the generated WSDL.
try {
this.importSchema = parameter.toURL().toString();
} catch (java.io.IOException ioe) {
throw new BuildException(ioe);
}
|
public void | setInput(java.io.File parameter)Optional attribute that indicates the name of the input wsdl file.
The output wsdl file will contain everything from the input wsdl
file plus the new constructs. If a new construct is already present
in the input wsdl file, it is not added. This option is useful for
constructing a wsdl file with multiple ports, bindings, or portTypes.
this.input = parameter.getPath();
|
public void | setLocation(java.lang.String parameter)The url of the location of the service. The name after the last slash or
backslash is the name of the service port (unless overridden by the -s
option). The service port address location attribute is assigned the
specified value.
this.location = parameter;
|
public void | setLocationImport(java.lang.String parameter)the location of the interface WSDL when generating an implementation WSDL
Required when outputImpl is set
this.locationImport = parameter;
|
public void | setMethods(java.lang.String methods)If this option is specified, only the indicated methods in your
interface class will be exported into the WSDL file. The methods list
must be comma separated. If not specified, all methods declared in
the interface class will be exported into the WSDL file
this.methods = methods;
|
public void | setNamespace(java.lang.String parameter)the target namespace. Required.
this.namespace = parameter;
|
public void | setNamespaceImpl(java.lang.String parameter)Namespace of the implementation WSDL.
this.namespaceImpl = parameter;
|
public void | setOutput(java.io.File parameter)The name of the output WSDL file.
If not specified, a suitable default WSDL file is written into
the current directory.
this.output = parameter.getPath();
|
public void | setOutputImpl(java.io.File parameter)Use this option to indicate the name of the output implementation WSDL
file. If specified, Java2WSDL will produce separate interface and implementation
WSDL files. If not, a single WSDL file is generated
this.outputImpl = parameter.getPath();
|
public void | setPortTypeName(java.lang.String parameter)Indicates the name to use use for the portType element.
If not specified, the class-of-portType name is used.
this.portTypeName = parameter;
|
public void | setServiceElementName(java.lang.String serviceElementName)the name of the service element.
If not specified, the service element is the portTypeNameService.
this.serviceElementName = serviceElementName;
|
public void | setServicePortName(java.lang.String parameter)service port name (obtained from location if not specified)
this.servicePortName = parameter;
|
public void | setSoapAction(java.lang.String soapAction)The setter for the "soapAction" attribute
this.soapAction = soapAction;
|
public void | setStopClasses(java.lang.String stopClasses)Comma separated list of classes which stop the Java2WSDL
inheritance search.
this.stopClasses = stopClasses;
|
public void | setStyle(java.lang.String style)The style of the WSDL document: RPC, DOCUMENT or WRAPPED.
If RPC, a rpc/encoded wsdl is generated. If DOCUMENT, a
document/literal wsdl is generated. If WRAPPED, a
document/literal wsdl is generated using the wrapped approach.
this.style = style;
|
public void | setTypeMappingVersion(TypeMappingVersionEnum parameter)the default type mapping registry to use. Either 1.1 or 1.2.
Default is 1.1
this.typeMappingVersion = parameter.getValue();
|
public void | setUse(java.lang.String use)Set the use option
this.use = use;
|
public void | setUseInheritedMethods(boolean parameter)should inherited methods be exported too? Default=false
this.useInheritedMethods = parameter;
|
public void | traceParams(int logLevel)trace out parameters
log("Running Java2WsdlAntTask with parameters:", logLevel);
log("\tnamespace:" + namespace, logLevel);
log("\tPkgtoNS:" + namespaceMap, logLevel);
log("\tlocation:" + location, logLevel);
log("\toutput:" + output, logLevel);
log("\timportSchema:" + importSchema, logLevel);
log("\tinput:" + input, logLevel);
log("\tclassName:" + className, logLevel);
log("\tservicePortName:" + servicePortName, logLevel);
log("\tportTypeName:" + portTypeName, logLevel);
log("\tbindingName:" + bindingName, logLevel);
log("\timplClass:" + implClass, logLevel);
log("\tinheritance:" + useInheritedMethods, logLevel);
log("\texcluded:" + exclude, logLevel);
log("\tstopClasses:" + stopClasses, logLevel);
log("\ttypeMappingVersion:" + typeMappingVersion, logLevel);
log("\tstyle:" + style, logLevel);
log("\toutputImpl:" + outputImpl, logLevel);
log("\tuse:" + use, logLevel);
log("\tnamespaceImpl:" + namespaceImpl, logLevel);
log("\tlocationImport:" + locationImport, logLevel);
log("\tserviceElementName:" + serviceElementName, logLevel);
log("\tmethods:" + methods, logLevel);
log("\textraClasses:" + extraClasses, logLevel);
log("\tsoapAction:" + soapAction, logLevel);
log("\tclasspath:" + classpath, logLevel);
|
protected void | validate()validation code
if(className==null || className.length() ==0) {
throw new BuildException("No classname was specified");
}
if(location==null || location.length() == 0) {
throw new BuildException("No location was specified");
}
|