【webservice】關於完整的webservice發布系統的開發思路

來源:互聯網
上載者:User

標籤:webservice   axis   

假如知道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


【webservice】關於完整的webservice發布系統的開發思路

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.