【webservice】关于完整的webservice发布系统的开发思路

假如知道webservice的服务端、客户端是怎么弄了,但是没弄过复杂业务的webservice,可以参考一下这个示例工程(菜鸟请看,老鸟勿喷)。

该webservice接口工程实现的业务如下:

1、身份验证:调用方(下称“用户”)的账号密码是否正确;

2、接口状态:该webservice接口是否共享公开;

3、权限:调用方是否具有访问权限;

4、流量:用户在单位时间里的访问次数;

5、日志记录:记录用户访问该接口的参数、时间、是否成功调用;

这里重点是提供方案哦,大概地,设计这个webservice服务端的类如下:

import common.action.ServiceUtil;

public class ThisServer extends SuperServer{

        private String interfaceName="This_Service";//接口名,log日志记录用

        public String tXZL_QueryQry(String interfaceUser, String interfacePassword, String query1, String query2){ //供外部调用的方法

              String methodName = "tXZL_QueryQry";//方法名,log日志记录用

              String parameters = query1+"_"+query2;

              int responseCode = 0;  //接口调用结果码,0为成功调用

             if( check(interfaceUser, interfacePassword) ){//1、身份验证:调用方(下称“用户”)的账号密码是否正确;

                     responseCode  =  1;

                     ServiceUtil.error(responseCode,  interfaceUser ,  interfaceName, methodName , parameters  );//ServiceUtil进行log日志记录(录入到表或者log文档,代码自行实现吧)

              }      

              if(  ServiceUtil.checkITF( interfacePassword) ){ //2、接口状态:接口是否共享开放;

                     responseCode =  2;

                     ServiceUtil.error(responseCode,  interfaceUser ,  interfaceName, methodName , parameters  );//日志记录

                     return ""+responseCode  ;

              }            

              if(  ServiceUtil.checkAuth(interfaceUser, interfacePassword) ){//3、权限:调用方是否具有访问权限;

                     responseCode  =  3;

                     ServiceUtil.error(responseCode,  interfaceUser ,  interfaceName, methodName , parameters  );//日志记录

                     return ""+responseCode;

              }          

              if(  ServiceUtil.checkFlow(interfaceUser, interfacePassword) ){//4、流量:用户在单位时间里的访问次数;

                     responseCode  =  4;

                     ServiceUtil.error(responseCode,  interfaceUser ,  interfaceName, methodName , parameters  );//日志记录

                     return ""+responseCode;

              }

              if( responseCode ==0 ){

                     try{

                              xxxxxxxxxxxxxxxx.........; // 主要的业务代码;

                              ServiceUtil.error(responseCode,  interfaceUser ,  interfaceName, methodName , parameters  );//日志记录

                              return ""+responseCode+“..............”;

                     }catch(Exception e){

                              responseCode = 5; //接口异常

                              ServiceUtil.error(responseCode,  interfaceUser ,  interfaceName, methodName , parameters  );//日志记录

                    }

             }

        }

}

上面代码省略了细节部分,其实省略掉的代码,大概就是数据库查询、字符串比较等等。那么,webservice接口按照这样的套路进行开发,另外可以写一个jsp系统用于接口、用户的配置,例如接口管理、用户管理、接口权限配置、接口流量配置、接口调用日志分析,当然,前端要好看,功能在细节上要到位,最后就能够整合成完美运行的webservice接口发布系统。

转载请说明出自Whilejolly:http://blog.csdn.net/seedingly/article/details/39050613


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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值