webservice之根据wsdl文件生成客户端工具类(Axis2)

Axis下载地址http://axis.apache.org/axis2/java/core/download.html
解压后bin文件夹下有
webservice之根据wsdl文件生成客户端工具类(Axis2)_第1张图片
基础生成命令

 wsdl2java.bat -uri http://localhost:8080/axis2/services/HelloUser?wsdl -p client -o D:\workspace\WSjava

-uri 是wsdl文件的路径,可以是本地也可以是网络路径
-p为包名
-o为生成文件路径可以是绝对也可以是相对
具体命令参见https://www.cnblogs.com/alfredinchange/p/5399170.html
调用

		    PFTMXStub stub = new PFTMXStub();
            Get_World params = new Get_World();
            prams.setAc(PftmxUtils.ac);//设置请求参数
            params.setPw(PftmxUtils.pw);        
            Get_WorldResponse response = stub.get_World(params);
            String str = response.getGet_World();//返回的xml字符串
            //解析xml得到信息

生成webservice客户端后导入项目所需的jar

		<dependency>
            <groupId>org.apache.axis2groupId>
            <artifactId>axis2artifactId>
            <version>${axis2.version}version>
            <type>pomtype>
            <scope>compilescope>
        dependency>
        <dependency>
            <groupId>org.apache.axis2groupId>
            <artifactId>axis2-adbartifactId>
            <version>${axis2.version}version>
            <type>jartype>
            <scope>compilescope>
        dependency>
        <dependency>
            <groupId>org.apache.axis2groupId>
            <artifactId>axis2-kernelartifactId>
            <version>${axis2.version}version>
            <type>jartype>
            <scope>compilescope>
        dependency>
        <dependency>
            <groupId>org.apache.axis2groupId>
            <artifactId>axis2-transport-httpartifactId>
            <version>${axis2.version}version>
        dependency>
        <dependency>
            <groupId>org.apache.axis2groupId>
            <artifactId>axis2-transport-localartifactId>
            <version>${axis2.version}version>
        dependency>

我的${axis2.version}设置为1.7.9

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