• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
  • Web 服務的測試模型與代碼摘錄[2]

    發表于:2010-04-15來源:作者:點擊數: 標簽:代碼webWebWEB模型
    Web 服務的測試模型與代碼摘錄[2] 軟件測試 if(action.equalsIgnoreCase("BUY")) System.out.println("BUYING qu ant ity: "+ quantity + " of symbol:" + symbol); // Invoke method to execute trade here. else if(action.equalsIgnoreCase("SELL")) Syst

      Web 服務的測試模型與代碼摘錄[2]   軟件測試

      if(action.equalsIgnoreCase("BUY"))

      System.out.println("BUYING quantity: "+ quantity + " of symbol:" + symbol);

      // Invoke method to execute trade here.

      else if(action.equalsIgnoreCase("SELL"))

      System.out.println("SELLING quantity: "+ quantity + " of symbol:" + symbol);

      // Invoke method to execute trade here.

      else

      {

      System.out.println("INVALID action: "+ action);

      throw new SOAPFaultException(new QName( "http://StockTrade/execute", "ServerFailed" ),

      "Invalid Action:" + action,

      null,

      detail);

      }

      return true;

      }

      代碼摘錄:Stock Trade Web Services

      該段摘錄的代碼是Stock Trade Web Services的“execute()”方法的實現代碼。該方法首先驗證輸入參數的有效性,驗證成功才執行功能。舉例說明,如果參數action是空值,它就會拋出一個SoapFaultException異常,用faultstring參數(第二個參數)說明造成異常的原因。為了舉例說明,在對參數 symbol進行相似的驗證之后,Web Services給出了處理機。在實際的情況下,商業邏輯應該在此位置中實現:

      try{

      // Setup the global JAXM message factory

      System.setProperty("javax.xml.soap.MessageFactory",

      "weblogic.webservice.core.soap.MessageFactoryImpl");

      // Setup the global JAX-RPC service factory

      System.setProperty( "javax.xml.rpc.ServiceFactory",

      "weblogic.webservice.core.rpc.ServiceFactoryImpl");

      StockTrade_Impl ws = new StockTrade_Impl();

      StockTradePort port = ws.getStockTradePort();

      boolean returnVal = port.execute(action, symbol, quantity);

      System.out.println("The webservice got back the following result:" + returnVal);

      }catch(Exception e) {

      }

    原文轉自:http://www.kjueaiud.com

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>