📄 java2wsdlanttask.java
字号:
/** * 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 * @param parameter */ public void setOutputImpl(File parameter) { this.outputImpl = parameter.getPath(); } /** * 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. * @param parameter a URL */ public void setLocation(String parameter) { this.location = parameter; } /** * the location of the interface WSDL when generating an implementation WSDL * Required when <tt>outputImpl</tt> is set * @param parameter URL? */ public void setLocationImport(String parameter) { this.locationImport = parameter; } /** * the class name to import, eg. org.example.Foo. Required. * The class must be on the classpath. * @param parameter fully qualified class name */ public void setClassName(String parameter) { this.className = parameter; } /** * Sometimes extra information is available in the implementation class * file. Use this option to specify the implementation class. * @param parameter */ public void setImplClass(String parameter) { this.implClass = parameter; } /** * service port name (obtained from location if not specified) * @param parameter portname */ public void setServicePortName(String parameter) { this.servicePortName = parameter; } /** * Indicates the name to use use for the portType element. * If not specified, the class-of-portType name is used. * @param parameter */ public void setPortTypeName(String parameter) { this.portTypeName = parameter; } /** * The name to use use for the binding element. * If not specified, the value of the * <tt>servicePortName</tt> + "SoapBinding" is used. * @param parameter */ public void setBindingName(String parameter) { this.bindingName = parameter; } /** * the target namespace. Required. * @param parameter */ public void setNamespace(String parameter) { this.namespace = parameter; } /** * Namespace of the implementation WSDL. * @param parameter */ public void setNamespaceImpl(String parameter) { this.namespaceImpl = parameter; } /** * should inherited methods be exported too? Default=false * @param parameter */ public void setUseInheritedMethods(boolean parameter) { this.useInheritedMethods = parameter; } /** * Comma separated list of methods to exclude from the wsdl file. * @param exclude */ public void setExclude(String exclude) { this.exclude = exclude; } /** * Comma separated list of classes which stop the Java2WSDL * inheritance search. * @param stopClasses */ public void setStopClasses(String stopClasses) { this.stopClasses = stopClasses; } /** * 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. * @param style */ public void setStyle(String style) { this.style = style; } /** * add a mapping of namespaces to packages */ public void addMapping(NamespaceMapping mapping) { mappings.addMapping(mapping); } /** * add a mapping of namespaces to packages */ public void addMappingSet(MappingSet mappingset) { mappings.addMappingSet(mappingset); } /** * the default type mapping registry to use. Either 1.1 or 1.2. * Default is 1.1 * @param parameter new version */ public void setTypeMappingVersion(TypeMappingVersionEnum parameter) { this.typeMappingVersion = parameter.getValue(); } /** * 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 * @param methods list of methods */ public void setMethods(String methods) { this.methods = methods; } /** * Set the use option */ public void setUse(String use) { this.use = use; } /** * the name of the service element. * If not specified, the service element is the <tt>portTypeName</tt>Service. * @param serviceElementName */ public void setServiceElementName(String serviceElementName) { this.serviceElementName = serviceElementName; } /** * A comma separated list of classes to add to the classpath. */ public void setExtraClasses(String extraClasses) { this.extraClasses = extraClasses; } /** * The setter for the "soapAction" attribute */ public void setSoapAction( String soapAction ) { this.soapAction = soapAction; } /** * Nested element for Complex Types. * Each Complex Type uses the following fields: * @param ct */ public void addComplexType(ComplexType ct) { complexTypes.add(ct); } /** * Set the optional classpath * * @param classpath the classpath to use when loading class */ public void setClasspath(Path classpath) { createClasspath().append(classpath); } /** * Set the optional classpath * * @return a path instance to be configured by the Ant core. */ public Path createClasspath() { if (classpath == null) { classpath = new Path(getProject()); classpath = classpath.concatSystemClasspath(); } return classpath.createPath(); } /** * Set the reference to an optional classpath * * @param r the id of the Ant path instance to act as the classpath */ public void setClasspathRef(Reference r) { createClasspath().setRefid(r); } /** * Adds a system property that tests can access. * @param sysp environment variable to add */ public void addSysproperty(Environment.Variable sysp) { commandline.addSysproperty(sysp); } /** * Sets the deploy flag * @param deploy true if deploy mode */ public void setDeploy(boolean deploy) { this.isDeploy = deploy; } /** * Generate the server side artifacts from the generated WSDL * * @param j2w the Java2WSDL emitter * @param wsdlFileName the generated WSDL file * @throws Exception */ protected void generateServerSide(Emitter j2w, String wsdlFileName) throws Exception { 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); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -