Web Services

1.3 服务端和客户端代码生成
利用Axis2工具的WSDL2Java命令自动生成JAVA代码,进入cmd命令行模式,运行命令WSDL2Java(运行命令的前提是要安装axis2-std-1.1工具,这个工具会在开发包中提供):
 生成服务端代码命令
Business:
D:/axis2-1.1/bin/WSDL2Java -uri D:/axis2-1.1/wsdl/CBSInterface_BusinessMgr.wsdl -p com.huawei.bus.ws.skeleton -d xmlbeans -s -ss -sd -ssi -o D:/axis2-1.1/wsdl/WebServiceCode/bussiness
Account:
D:/axis2-1.1/bin/WSDL2Java -uri D:/axis2-1.1/wsdl/CBSInterface_AcctMgr.wsdl -p com.huawei.bus.ws.skeleton -d xmlbeans -s -ss -sd -ssi -o D:/axis2-1.1/wsdl/WebServiceCode/account

 生成客户端包代码命令
Business:
D:/axis2-1.1/bin/WSDL2Java -uri D:/axis2-1.1/wsdl/CBSInterface_BusinessMgr.wsdl -p com.huawei.bus.ws.skeleton -d xmlbeans -s -o D:/axis2-1.1/wsdl/WebServiceCode/bussinessclient
Account:
D:/axis2-1.1/bin/WSDL2Java -uri D:/axis2-1.1/wsdl/CBSInterface_AcctMgr.wsdl -p com.huawei.bus.ws.skeleton -d xmlbeans -s -o D:/axis2-1.1/wsdl/WebServiceCode/accountclient


WSDL2Java命令参数说明:
-uri  指定*.wsdl文件,可以带具体路径;
-p  指定生成代码的包名
-d xmlbeans  使用不同的数据绑定方法;
-o  指定生成代码放置的路径;
-ss 表示要生成服务端代码;
-ssi 表示要生成代码中,先生成接口类,再生成实现类;

1.4 Ant工具打包
在上一节中,利用axis2工具自动生成代码的时候,客户端和服务端都会产生对应的代码、资源和build.xml文件等,打包步骤:
 新建java工程:
1. 把生成的如下服务端代码拷贝到该工程下

2. 删除skeleton类(\src\com\huawei\bus\ws\skeleton\CBSInterfaceAccountMgrServiceSkeleton.java)
3. 把客户端的stub类(\src\com\huawei\bus\ws\skeleton\CBSInterfaceAccountMgrServiceStub.java)拷贝到上面服务端代码src的(\src\com\huawei\bus\ws\skeleton)目录下
4. 导入axis2的lib包(目录在工具/axis2-1.1/bin下)
5. 编辑build.xml,在末尾加入下面target
<target if="jars.ok" name="build.aar" depends="compile.test">
<copy toDir="${classes}/META-INF" failonerror="false">
<fileset dir="${resources}">
<include name="services.xml"/>
</fileset>
</copy>
<jar destfile="${lib}/${name}.aar">
<fileset dir="${classes}">
<include name="**/META-INF/services.xml"/>
</fileset>
</jar>
</target>
<target depends="jar.client, build.aar" name="build.all"></target>
6. 执行ant

你可能感兴趣的:(Web,xml,ant)