Advertisement
mrk1989

Wrapper.java

Oct 6th, 2016
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.91 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package com.indra.soap;
  7.  
  8.  
  9. import com.indra.Application.ApplicationManagementSoapBindingStub;
  10. import com.indra.Application.Output;
  11. import java.io.File;
  12. import java.net.MalformedURLException;
  13. import java.net.URL;
  14. import java.rmi.RemoteException;
  15. import java.util.Properties;
  16. import org.apache.log4j.PropertyConfigurator;
  17.  
  18.  
  19.  
  20. /**
  21. *
  22. * @author User
  23. */
  24. public class Wrapper {
  25.  
  26. private static Properties props = new Properties();
  27.  
  28. public static final String ENV_CONFIG_HOME = "CATALINA_BASE";
  29. public static final String ENV_CONFIG_NAME = "conf";
  30. public static final String NAME_FILE_PROP = "ws.ini";
  31.  
  32. private String wsUrl = "";
  33. private ApplicationManagementSoapBindingStub stub;
  34.  
  35. public Wrapper(String url )
  36. {
  37. wsUrl=url;
  38.  
  39.  
  40. }
  41.  
  42. private static boolean isNumeric(String str)
  43. {
  44. try
  45. {
  46. double d = Double.parseDouble(str);
  47. }
  48. catch(NumberFormatException nfe)
  49. {
  50. return false;
  51. }
  52. return true;
  53. }
  54.  
  55. /**
  56. *
  57. * @param dnis
  58. * @return Output
  59. * */
  60.  
  61. public Output applicationManagement(String dnis){
  62. Output out =null;
  63. String appo="";
  64. String config_path="";
  65. try
  66. {
  67. config_path = System.getenv(ENV_CONFIG_HOME);
  68. config_path += File.separator + ENV_CONFIG_NAME;
  69. config_path += File.separator + NAME_FILE_PROP;
  70. PropertyConfigurator.configure(config_path);
  71. appo = props.getProperty("APPLICATION_MANAGEMENT_Timeout");
  72. stub = new ApplicationManagementSoapBindingStub(new URL(wsUrl), null);
  73. if(appo!=null && isNumeric(appo))
  74. stub.setTimeout((Integer.parseInt(appo))*1000);
  75. else
  76. stub.setTimeout(10000);
  77. out = stub.applicationManagement(dnis);
  78. }
  79. catch (MalformedURLException me )
  80. {
  81. System.out.println("Errore URL= " + wsUrl );
  82. System.out.println("Errore in Wrapper.getIVRService() MalformedURLException ! " + me.getMessage() );
  83. // e.printStackTrace();
  84. }
  85. catch (RemoteException re )
  86. {
  87. System.out.println("URL= " + wsUrl );
  88. System.out.println("Errore in Wrapper.getIVRService() RemoteException! " + re.getMessage() );
  89. // e.printStackTrace();
  90. }
  91. catch (Exception e )
  92. {
  93.  
  94. System.out.println("Errore in Wrapper.getIVRService()! " + e.getMessage() );
  95. // e.printStackTrace();
  96. }
  97. return out;
  98. }
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement