07-09-2015 05:29 PM
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
07-24-2015 10:53 AM
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.
07-24-2015 10:57 AM
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")
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide