So easy Webservice 4.Java方式访问WebService(使用jdk1.6以上 wsimport命令)

 

1.选中要调用的服务单击”服务说明”

2.获取wsdl文件.使用JDK1.6以上的版本的wsimport命令

a) 例如选中:http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx?WSDL

b) 获取wsdl文件.使用JDK1.6以上的版本的wsimport命令:cmd中使用wsimport命令:

C:\ws>wsimport -s(-c) . -p com.mlxs.ws.mobilecode http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx?WSDL

 

 

生成文件:

c) 可以把class文件打成jar包 jar cvf  test.jar 打包目录

3.拷贝的项目中调参考WSDL用即可调用源码如下:

public static void main(String[] args) {
        MobileCodeWS mobileCodeWs=new MobileCodeWS();
        MobileCodeWSSoap mobileCodeWSSoap=mobileCodeWs.getMobileCodeWSSoap();
        String tel=mobileCodeWSSoap.getMobileCodeInfo("18373551982",null);
        System.out.println(tel);
    }

 

 

posted @ 2016-01-27 16:39  艺言弈行  阅读(377)  评论(0编辑  收藏  举报