首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

webservice自说自话-透过已经生成的wsdl文件生成java代码的工具

2012-11-21 
webservice自说自话-通过已经生成的wsdl文件生成java代码的工具package com.toolsimport java.util.Mapi

webservice自说自话-通过已经生成的wsdl文件生成java代码的工具

package com.tools;import java.util.Map;import javax.wsdl.Definition;import org.apache.axis2.description.AxisService;import org.apache.axis2.tool.codegen.WSDL2JavaGenerator;import org.apache.axis2.tool.codegen.eclipse.util.WSDLPropertyReader;import org.apache.axis2.wsdl.codegen.CodeGenConfiguration;import org.apache.axis2.wsdl.codegen.CodeGenerationEngine;/** * 根据WSDL文件生成JAVA代码.<br> * 需要使用是否请自己写个Main函数. */public class WsdlCodingTools{    /**     * 生成JAVA代码.     * @throws Exception 发生异常.     * @see [类、类#方法、类#成员]     */    public static void coding()        throws Exception //NOPMD    {        // wsdl--wsdl本地或者网络路径        String wsdl = "mmm";        // 是否同步        boolean isSync = true;        // 是否服务端        boolean isServerSide = false;        // 输出路径--直到工程名就可以了        String outLocationUrl = "mmm";        // package        String packageName = "com.client";        WSDL2JavaGenerator generator = new WSDL2JavaGenerator();        AxisService axisService = generator.getAxisService(wsdl);        Map<?, ?> fillOptionMap =            generator.fillOptionMap(false,                isSync,                isServerSide,                isServerSide,                true,                false,                null,                null,                "adb",                wsdl,                packageName,                "java",                outLocationUrl,                null,                true);        CodeGenConfiguration codegenConfig = new CodeGenConfiguration(fillOptionMap);        codegenConfig.addAxisService(axisService);        //set the wsdl definision for codegen config for skeleton generarion.        WSDLPropertyReader reader = new WSDLPropertyReader();        reader.readWSDL(wsdl);        Definition wsdlDefinition = reader.getWsdlDefinition();        codegenConfig.setWsdlDefinition(wsdlDefinition);        //set the baseURI        codegenConfig.setBaseURI(generator.getBaseUri(wsdl));        new CodeGenerationEngine(codegenConfig).generate();    }    public static void main(String[] args)    {        try        {            WsdlCodingTools.coding();        }        catch (Exception e)        {            // TODO Auto-generated catch block            e.printStackTrace();        }    }}

?

热点排行