一.相关介绍
1.1 Web Server
Web服务器传送(serves)页面使浏览器可以浏览,然而应用程序服务器提供的是客户端应用程序可以调用(call)的方法(methods)。确切一点Web服务器专门处理HTTP请求,但是应用程序服务器是通过很多协议来为应用程序提供(serves)商业逻辑。
1.2 Axis2
Axis2是下一代 Apache Axis。Axis2 虽然由 Axis 1.x 处理程序模型提供支持,但它具有更强的灵活性并可扩展到新的体系结构。Axis2 基于新的体系结构进行了全新编写,而且没有采用 Axis 1.x 的常用代码。支持开发 Axis2 的动力是探寻模块化更强的体系结构,这种体系结构可以很容易地插入到其他相关 Web 服务标准和协议的实现中。
二.相关服务
Web服务网站:http://www.webxml.com.cn/zh_cn/web_services.aspx
三.环境配置
下载Axis2的最新版本Axis2:
http://ws.apache.org/axis2/download/1_4_1/download.cgi在IDEA中配置Axis2的环境;
新建一个Java WebServer Client,根据提示完成相关引导;
确定后会生成相关代码,其中以Proxy为结尾的为我们所需要使用的类;
四.使用相关
4.1 主要过程
使用JetBrain的Ideal中的Web Server Client,建立相应的程序,再使用Java Swing编写桌面程序,达到使用的效果
4.2 主要代码内容
4.2.1 手机号相关信息查询
public static String GetPhoneInfo(String phoneNum){
String result = "";
MobileCodeWSSoapProxy mobileCodeWSSoapProxy = new MobileCodeWSSoapProxy();
try {
result = mobileCodeWSSoapProxy.getMobileCodeInfo(phoneNum," ");
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return result;
}
4.2.2 地区天气情况查询
public static String[] GetWeather(String code){
WeatherWSSoapProxy weatherWSSoapProxy = new WeatherWSSoapProxy();
String[] strings = null;
try {
strings = weatherWSSoapProxy.getWeather(code," ");
} catch (RemoteException e) {
e.printStackTrace();
}
return strings;
}
4.2.3 IP地址相关信息查询
public static String[] GetIpInfo(String ipAddress){
IpAddressSearchWebServiceSoapProxy ipAddressSearchWebServiceSoapProxy = new IpAddressSearchWebServiceSoapProxy();
String[] result=null;
try {
result = ipAddressSearchWebServiceSoapProxy.getCountryCityByIp(ipAddress);
} catch (RemoteException e) {
e.printStackTrace();
}
return result;
}