10.1.2  Example of a Web Service JavaBean 
Followed is a Java source code listing of the actual Web Service JavaBean. The JSP listing in previous 
chapter passes 
service 
parameter to the JavaBean and then calls the 
process()
 method. 
package webservice; 
public class wsBean extends xfij.webserver.WebServiceBase { 
  public wsBean() { 
   setWebServiceName("testWebService"); 
  } 
  public synchronized String process() { 
   WRPCBroker broker = null; 
   try { 
    broker = getBroker(); 
   } catch (Exception ex) { 
    return "Error in a database operation: "+ex.getMessage(); 
   }    
   try { 
    if (service.equals("status")) { 
     StringBuffer b = new StringBuffer(); 
     b.append("Live connection: "+broker.isConnected()+""); 
     b.append("Started: "+getStartupTime()+""); 
     return b.toString(); 
        } 
   // reply to some service, or... 
    return "No such service:"+service+""; 
   } catch (Exception ex) { 
    ex.printStackTrace(); 
    return ""; 
   } finally { service = ""; } 
  } 
  public synchronized void setService(String service) { 
   this.service = service; 
  } 
  private String service = ""; 
} 
40 






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

servlets web hosting

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Jsp Web Hosting Cheapest Web Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved