利用ant根据wsdl自动生成客户端代码

在提供了wsdl的情况了,可以利用ant自动生成客户端代码,其实是用了jdk的wsimport命令。build.xml如下

<?xml version="1.0" encoding="UTF-8"?>
<project name="WSClient" default="weblogicwsclient" basedir=".">
    <property name="src.dir" value="${basedir}/src/main/java" />
    <path id="build.classpath" description="设置类路径">
        <fileset dir="${basedir}/lib">
            <include name="*.jar">
            </include>
        </fileset>
    </path>

    <target name="weblogicwsclient" description="生成webservice客户端代码">
        <taskdef name="wlwsimport" classname="com.sun.tools.ws.ant.WsImport" classpathref="build.classpath" />
        <wlwsimport wsdl="http://10.196.149.42:7001/services/ClientResInfoService?wsdl" sourcedestdir="${src.dir}" package="com.alibaba.datacollector.res.ws.client" keep="true" verbose="true" destdir="${basedir}/bin" />
    </target>
</project>

 只要设置好wsdl路径和package参数,运行ant就可以了.

2.用到的jar 

activation.jar

commons-beanutils-1.7.0.jar

jaxb-api.jar

jaxb-impl.jar

jaxb-xjc.jar

jaxws-rt.jar

jaxws-tools.jar

jboss-jaxws.jar

saaj-impl-1.3.2.jar

stax-ex.jar

streambuffer.jar 

你可能感兴趣的:(webservice,wsdl,ant)