Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp

oz jack

Greenhorn
+ Follow
since Jan 29, 2019
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by oz jack

Hi All,
      I will use JAXWS to expose a web service from a java method. However, the class contains a static main method and another method that needs to called before the service method. I am not sure how to refactor the methods in the class to enable me to expose the method "serviceMethod" as a web service.

Basically want to refactor the standalone java program and expose as a webservice. Please advise.


public class EpmQuery {
   public EpmQuery() {
       super();
   }
   
   
   public void execute() throws HFMException, Exception {
       //Create app
       Application app = new Application();
             

       //Retrieve loaded metadata
       Metadata metadata = new Metadata();
       metadata.displayMetadata();

       //Get all the clusters
       Cluster cluster = new Cluster();
       cluster.enumClusters();

       //Get the available cluster
       String strCluster = cluster.getAvailableCluster(app.getSsoToken());

       //Get all Servers
       String server = cluster.enumServers(strCluster);

       //Get all applications
       app.getApplications(strCluster, app.getSsoToken(), Locale.ENGLISH.getLanguage());

       String result = serviceMethod("S#Actual.Y#2005.P#January.W#<Scenario View>")
       
       

     
   }

public String serviceMethod(String pov) throws HFMException{
   DataCell dataCell = new DataCell();
        return dataCell.readDataCell(pov);

}

   
   public static void main(String[] args) {
       try {

           String epmOracleInstance = System.getProperty("EPM_ORACLE_INSTANCE");

           if (epmOracleInstance == null || epmOracleInstance.isEmpty()) {
               throw new Exception("EPM Instance home not set");
           }

       

           //Execute the demo application
           //This will create a new application, load metadata and print metadata
           EpmQuery epmq = new EpmQuery();
           epmq.execute();

       } catch (HFMException e) {
           e.printStackTrace();
           //Get error details
           System.out.println(e.getErrorCode());
           System.out.println(e.getHResult());
           System.out.println(e.getLocalizedMessage(Locale.ENGLISH));
           System.exit( -1 );
       } catch (Exception e) {
           e.printStackTrace();
           System.exit( -1 );
       }
   }
}



2 weeks ago