每次在控制台利用wsdl生成webservice java代码,都要找脚本,修改,记又记不住。最近正好此类项目比较多,抽了点时间写了个脚本,保存为wsdl2java.cmd,并保存到Windows/system32下,以后调用,直接在命令行执行下面的脚本即可:
wsdl2java http://localhost:8080/MyService/GetMessageService.asmx false com.dot618.myservice src
参数说明:
参数1 wsdl路径,可以是本地路径,也可以是http地址
参数2 是否生成服务端代码,缺省为false
参数3 包名,缺省为gen
参数4 保存的路径名,缺省为src
wsdl2java.cmd脚本:
@echo off
:Set JAVA_HOME=d:/Program/Java/jdk1.6.0_21
:Set AXIS_HOME=d:/Program/axis-1_4
if {%JAVA_HOME%}=={} (GOTO NOVAR)
if {%AXIS_HOME%}=={} (GOTO NOVAR)
echo using envionment variables:
echo JAVA_HOME=%JAVA_HOME%
echo AXIS_HOME=%AXIS_HOME%
SET URL=http://
SET SERVER_FLAG=
if {%1}=={} (GOTO ERROR) else (SET URL=%1)
if {%2}=={true} (Set SERVER_FLAG= --server-side --skeletonDeploy true)
if {%3}=={} (SET PACKAGE=gen) ELSE (SET PACKAGE=%3)
if {%4}=={} (SET OUTPUT=src) ELSE (SET OUTPUT=%4)
echo script is running:
echo "%JAVA_HOME%/bin/java -Djava.ext.dirs=%AXIS_HOME%/lib org.apache.axis.wsdl.WSDL2Java%SERVER_FLAG% %URL% -p %PACKAGE% -o %OUTPUT%"
%JAVA_HOME%/bin/java -Djava.ext.dirs=%AXIS_HOME%/lib org.apache.axis.wsdl.WSDL2Java%SERVER_FLAG% %URL% -p %PACKAGE% -o %OUTPUT%
echo.
echo success.
GOTO END
:ERROR
echo Axis 1.4 generate java client
echo [usage]
echo %0 [wsdl url] [if server-side] [package] [output]
echo.
GOTO END
:NOVAR
echo please export envionment variables JAVA_HOME and AXIS_HOME,then try again.
:END