WEB开发网
开发学院软件开发Java 基于WAS CE和Axis2开发Web Service应用 阅读

基于WAS CE和Axis2开发Web Service应用

 2010-03-19 00:00:00 来源:WEB开发网   
核心提示: 下面我们来重点看一下query方法的实现:publicOMElementquery(OMElementin){intflowerid=Integer.parseInt(in.getText());Stringinfo="Cannotquery!";try{//useaxis2

下面我们来重点看一下query方法的实现:

public OMElement query(OMElement in){ 
 int flowerid = Integer.parseInt(in.getText());  
 String info = "Can not query!"; 
 try { 
 //use axis2 datasource we deployed before 
 Context initContext = new InitialContext(); 
 Context envContext = (Context)initContext.lookup("java:/comp/env"); 
 DataSource ds = (DataSource)envContext.lookup("jdbc/DataSource"); 
    Connection con = ds.getConnection(); 
 Statement stmt = con.createStatement(); 
 ResultSet rs = stmt.executeQuery( 
               "SELECT * FROM FLOWER WHERE ID=" + flowerid ); 
 while (rs.next()) 
 { 
    info = "ID=" + rs.getInt("ID") + " NAME=" + rs.getString("NAME") + 
          " DESCRIPTION=" + rs.getString("DESCRI") + " PRICE=" + 
     
              rs.getDouble("PRICE"); 
 } 
 } catch(Exception e) { } 
   
 //create the OMElement for response 
 OMFactory fac = OMAbstractFactory.getOMFactory(); 
 OMNamespace omNs = fac.createOMNamespace("http://flowershop.com/", "flower"); 
 OMElement resp = fac.createOMElement("getFlowerInfo", omNs); 
 resp.setText(info); 
 return resp;    
} 

上一页  4 5 6 7 8 9 10  下一页

Tags:基于 WAS CE

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接