1.dos执行一个命令wsimort
D:\webService>wsimport -d . MobileCodeWS.xml
parsing WSDL...
[WARNING] Ignoring SOAP port "MobileCodeWSSoap12": it uses non-standard SOAP 1.2 binding.
You must specify the "-extension" option to use this binding.
line 199 of file:/D:/webService/MobileCodeWS.xml
[WARNING] ignoring port "MobileCodeWSHttpGet": no SOAP address specified. try running wsimport with -extension switch.
line 202 of file:/D:/webService/MobileCodeWS.xml
[WARNING] ignoring port "MobileCodeWSHttpPost": no SOAP address specified. try running wsimport with -extension switch.
line 205 of file:/D:/webService/MobileCodeWS.xml
Generating code...
Compiling code...
D:\webService>wsimport -d . MobileCodeWS.xml
parsing WSDL...
Generating code...
Compiling code...
D:\webService>
注意:把MobileCodeWS.xml的199以后的配置信息删掉
或者用-s可以再webService生产源代码和class文件
D:\webService>wsimport -s . MobileCodeWS.xml
parsing WSDL...
Generating code...
Compiling code...
D:\webService>
注意:查看当前目录下 把copy java文件
2.生产一个java客户端调用代码
把生产的java文件连同目录导入工程
3.创建一个工程,把代码导入
编写测试文件
package com.taxue.test;
import cn.com.webxml.MobileCodeWS;
import cn.com.webxml.MobileCodeWSSoap;
public class Mobiledemo {
public static void main(String[] args) {
MobileCodeWS ws = new MobileCodeWS();
MobileCodeWSSoap port = ws.getMobileCodeWSSoap();
String address = port.getMobileCodeInfo("13598362941", null);
System.out.println(address);
}
}
结果:13598362941:河南 商丘 河南移动全球通卡
4.建立客户端调用
查看 xml wsdl说明书
1:提供Service <wsdl:service name ="MobileCodeWS">
2.获取 Port <wsdl:port name="MobileCodeWSSoap" binding="tns:MobileCodeWSSoap">
3.获得 proType 方法集合 <wsdl:binding name="MobileCodeWSSoap" type="tns:MobileCodeWSSoap">
4 寻找方法 <wsdl:operation name="getMobileCodeInfo">
5填写参数 调用方法得到结果
手机:http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx