Hi all,
I am new to Custom Java and trying to learn it , i have code sample from internet but i don't know how to compile it and embed into my call flow in call studio
i have follow the instruction from Custom Java Classes with Call Studio but when i'll compile the code is error
import com.audium.server.AudiumException;
import com.audium.server.session.ActionElementData;
import com.audium.server.voiceElement.ActionElementBase;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.net.URL;
import java.net.URLConnection;
public class GetBilling extends ActionElementBase
{
static final int PREDICT_THRESHOLD = 3;
private static String vBilling;
public static void GetDataBill(String strDataBill)
throws Exception
{
vBilling = "0";
URL strBilling = new URL("http://192.168.1.2/cvp/wsclient.php?id=" + strDataBill);
URLConnection hpCon = strBilling.openConnection();
int len = hpCon.getContentLength();
if (len > 0)
{
BufferedReader in = new BufferedReader(
new InputStreamReader(strBilling.openStream()));
vBilling = in.readLine();
}
else
{
vBilling = "0";
}
System.out.println("Billing : " + vBilling);
}
public void doAction(String name, ActionElementData actionAPI)
throws AudiumException
{
String strCustID = actionAPI.getElementData("Customer Enter Digit", "value");
try
{
GetDataBill(strCustID);
}
catch (Exception e) {
System.out.println("0");
}
String balance = vBilling.trim();
if (balance == "0")
{
actionAPI.removeAllSessionData();
actionAPI.setSessionData("balance", balance);
}
else
{
String strSess = balance.substring(0, 1);
String strSess2 = balance.substring(1);
actionAPI.setSessionData("StsBilling", strSess);
actionAPI.setSessionData("ValBilling", strSess2);
if (strSess == "1")
{
actionAPI.setSessionData("StsBilling", "1");
actionAPI.setSessionData("balance", strSess2);
}
if (strSess == "2")
{
actionAPI.setSessionData("StsBilling", "2");
actionAPI.setSessionData("balance", strSess2);
}
if (strSess == "0")
{
actionAPI.setSessionData("StsBilling", "0");
actionAPI.setSessionData("balance", strSess2);
}
if (strSess == "9")
{
actionAPI.setSessionData("StsBilling", "9");
actionAPI.setSessionData("balance", "0");
}
if (strSess2.trim() == "")
actionAPI.setSessionData("balance", "0");
else
actionAPI.setSessionData("balance", strSess2);
}
}
}
please tell me the step by step
thx,
esraldi
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Hi, Are you getting a compilation error or a runtime error? Can you post more information about the error message?
If it's a run time error, look in the VXML Server error log.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
One thing that's wrong with your java code is that if you are doing string comparisons, you can't use == (that's just for number comparisons or comparing to null).
With strings, you must use the method equals or equalsIgnoreCase
strVar.equals("1")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Comments
0 comments
Please sign in to leave a comment.