基于xfire生成webservice在客户端的stub

  1. 增加xfire的jar

    src.dir=${basedir}/src
    lib.dir=E:/xfire-1.2.6/lib
    wsdl.dir=http\://localhost\:8888/webService_xfire/services/CaculatorService?wsdl


  2. 增加AntTask(build.xml)

    <?xml version="1.0" encoding="UTF-8"?>
    <project name="WebService" basedir="." default="gen-webservice">
    <property file="build.properties"></property>--导入配置文件
                                                                                                           
    <path id="project-classpath">
        <fileset dir="${lib.dir}">--源代码路径
            <include name="**/*.jar"/>--路径下所有以jar结尾的文件
        </fileset>
    </path>
                                                                                                           
    <target name="gen-webservice">
        <taskdef name="wsgen" classname="org.codehaus.xfire.gen.WsGenTask" classpathref="project-classpath"/>
        <wsgen outputDirectory = "${src.dir}" wsdl="${wsdl.dir}" package="com.test.client"/>
    ---outputDirectory 源代码输出路径,wsdl的访问路径,package是stub生成的包路径
    </target>
    </project>
  3. 配置文件

    src.dir=${basedir}/src
    lib.dir=E:/xfire-1.2.6/lib
    wsdl.dir=http\://localhost\:8888/webService_xfire/services/CaculatorService?wsdl


  4. 右击Run As ant build生成stub就ok了

你可能感兴趣的:(webservice,xfire,客户端,stub)