First of all, to get a good build WebService WSDL services, such as to achieve the domestic mobile phone numbers for attribution WEB service, its WSDL is: http:? //Ws.webxml.com.cn/WebServices/MobileCodeWS.asmx WSDL
Get the WSDL service opens in your browser to see whether it is normal:
Open cmd, run the command:
wsimport -p com -s . http://ws.webxml.com.cn/WebServices/MobileCodeWS.asmx?WSDL
Found resolve the location, copy the relevant files to the Java client:
Write the test class, directly call related interfaces:
import mobileWebService.MobileCodeWS; import mobileWebService.MobileCodeWSSoap; public class MobileWebServiceTest { public static void main(String[] args) { //获取webservice服务器对象(这里的类名,其实是从wsdl文件中的servicename标签中进行获取的) MobileCodeWS mobileCodeWS = new MobileCodeWS(); MobileCodeWSSoap m = mobileCodeWS.getMobileCodeWSSoap(); String str = m.getMobileCodeInfo("手机号码", ""); System.out.println(str); } }
运行结果:
WebService服务遇到问题及解决办法:https://www.cnblogs.com/Big-Boss/p/11912679.html