Web Service实例测试

一.相关介绍

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

三.环境配置

  1. 下载Axis2的最新版本Axis2:
    http://ws.apache.org/axis2/download/1_4_1/download.cgi

  2. 在IDEA中配置Axis2的环境;

  3. 新建一个Java WebServer Client,根据提示完成相关引导;

  4. 确定后会生成相关代码,其中以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;
    }

五.运行结果

手机号查询

IP地址信息查询

六.其他

程序源代码:https://github.com/BlackJocker1995/MiddlewareWork04

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值