Genesys CTI User Forum

Genesys CTI User Forum => Genesys-related Development => Topic started by: deadmeat on July 16, 2012, 07:08:59 AM

Title: Assigning java function output to VXML variable in GVP 7.6
Post by: deadmeat on July 16, 2012, 07:08:59 AM
Hello everyone! Would be very grateful if someone could help me. The goal is to insert some java code into the jsp page, and assign the output to VXML Variable. Here is the example:
[code]
<?xml version="1.0" encoding="UTF-8"?><%@page contentType="text/xml" pageEncoding="UTF-8" buffer="none"%>
<vxml xmlns="http://www.w3.org/2001/vxml"  xml:lang="ru-RU" version="2.0" application="root.jsp">
    <%@page import="java.util.Date, java.sql.Timestamp"%>
    <%@taglib prefix="bakcellivr" uri="/WEB-INF/tlds/bakcellivr"%>
    <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
    <%@taglib prefix="ad" tagdir="/WEB-INF/tags/attach_data"%>
    <%@taglib prefix="debug" uri="/WEB-INF/tlds/debug"%>

<%
java.sql.Timestamp timestamp = new Timestamp(System.currentTimeMillis());
pageContext.setAttribute("timestamp ", timestamp);
System.out.println(timestamp);
%>

    <form>
        <!-- Get the attach data -->
        <ad:get name="attach_data">
            <param name="LANGUAGE" value=""/>
            <param name="SERVICE_TYPE" value=""/>
            <param name="CUSTOMER_TYPE" value=""/>
            <param name="CUSTOMER_VALUE" value=""/>
            <param name="WB_INDICATOR" value=""/>
            <param name="SERVICE_ID" value=""/>
            <param name="SUBTREE_ID" value=""/>
            <param name="MENU_ID" value=""/>
            <param name="SERVED_ANI" value=""/>
            <param name="IVR_BACK" value=""/>
            <param name="RP_LEVEL_1_TARGET" value=""/>
            <param name="MENU_PARENT" value=""/>
            <param name="MENU_ACTION" value=""/>
            <param name="MENU_TARGET" value=""/>
        </ad:get>

        <block>

            <assign name="OBMESSAGE" expr="${bakcellivr:getIvrOption('obmessage')}"/>
            <c:set var="IVRTenter" value="${timestamp}"/>
   
            <if cond="attach_data.LANGUAGE != undefined">
                <assign name="LANGUAGE" expr="attach_data.LANGUAGE"/>
            </if>
            <if cond="attach_data.SERVICE_ID != undefined">
                <assign name="SERVICE_ID" expr="attach_data.SERVICE_ID"/>
            </if>
            <if cond="attach_data.SUBTREE_ID != undefined">
                <assign name="SUBTREE_ID" expr="attach_data.SUBTREE_ID"/>
            </if>
            <if cond="attach_data.MENU_ID != undefined">
                <assign name="MENU_ID" expr="attach_data.MENU_ID"/>
            </if>
            <if cond="attach_data.SERVICE_TYPE != undefined">
                <assign name="SERVICE_TYPE" expr="attach_data.SERVICE_TYPE"/>
            </if>
            <if cond="attach_data.CUSTOMER_TYPE != undefined">
                <assign name="CUSTOMER_TYPE" expr="attach_data.CUSTOMER_TYPE"/>
            </if>
            <if cond="attach_data.CUSTOMER_VALUE != undefined">
                <assign name="CUSTOMER_VALUE" expr="attach_data.CUSTOMER_VALUE"/>
            </if>
            <if cond="attach_data.WB_INDICATOR != undefined">
                <assign name="WB_INDICATOR" expr="attach_data.WB_INDICATOR"/>
            </if>     
            <if cond="attach_data.SERVED_ANI != undefined">
                <assign name="SERVED_ANI" expr="attach_data.SERVED_ANI"/>
            </if>

            <if cond="attach_data.IVR_BACK != undefined">
                <assign name="IVR_BACK" expr="attach_data.IVR_BACK"/>
            </if>

            <if cond="attach_data.MENU_PARENT != undefined">
                <assign name="MENU_PARENT" expr="attach_data.MENU_PARENT"/>
            </if>

            <if cond="attach_data.MENU_ACTION != undefined">
                <assign name="MENU_ACTION" expr="attach_data.MENU_ACTION"/>
            </if>
            <if cond="attach_data.MENU_TARGET != undefined">
                <assign name="MENU_TARGET" expr="attach_data.MENU_TARGET"/>
            </if>

            <if cond="attach_data.RP_LEVEL_1_TARGET != undefined">
                <assign name="RP_LEVEL_1_TARGET" expr="attach_data.RP_LEVEL_1_TARGET"/>
            </if>

            <debug:message message="start.jsp. ANI: ${param.ANI}"/>
            <debug:message message="start.jsp. DNIS: ${param.DNIS}"/>

            <!-- AV: VAR TEST -->
            <assign name="CONNID" expr="session.genesys.sessionid"/>

            <submit next="session.jsp" namelist="IVRTEnter CONNID ANI DNIS LANGUAGE CUSTOMER_TYPE CUSTOMER_VALUE SERVICE_TYPE WB_INDICATOR OBMESSAGE SERVICE_ID SUBTREE_ID MENU_ID RP_LEVEL_1_TARGET AGENT_LEVEL_1_TARGET IVR_BACK MENU_PARENT MENU_ACTION MENU_TARGET"/>
     
        </block>
    </form>
</vxml>
[/code]
But unfortunately the value of IVRTenter variable remains empty :-(
Title: Re: Assigning java function output to VXML variable in GVP 7.6
Post by: René on July 16, 2012, 09:57:02 AM
Hi,

Have you tried following?
[code]<assign name="OBMESSAGE" expr="${bakcellivr:getIvrOption('obmessage')}"/>
<assign name="IVRTenter" value="<%=timestamp%>"/>[/code]

R.
Title: Re: Assigning java function output to VXML variable in GVP 7.6
Post by: deadmeat on July 16, 2012, 10:28:17 AM
Hasn't worked :-(
[code]
[2012/07/16 10:07:36.194] 204A0 BeginSession.cpp:555 C=12:L=1:U=321:D=E_12_137 Exception caught within <ACCEPT_CALL>.Execute:URL is http://172.29.0.9:8082/BAKCELLIVR/vxml/start.jsp?NEXTACTION=START&ANI=994555902585&DID=8888&SESSIONID={008B4E3A-E7E7-1003-A2BA-AC1D000EAA77}
[2012/07/16 10:07:36.196] 204A0 XMLData.cpp:2570 C=12:L=1:U=321:D=E_12_234 Trap Sent:The ErrorString is :NETWORK_ERROR : Server Error  ErrorURL: http://172.29.0.9:8082/BAKCELLIVR/vxml/start.jsp?NEXTACTION=START&ANI=994555902585&DID=8888&SESSIONID={008B4E3A-E7E7-1003-A2BA-AC1D000EAA77}: CCThread:Inbound PortNumber:7021
[2012/07/16 10:07:36.199] 204A0 XMLData.cpp:2570 C=12:L=1:U=321:D=E_12_234 Trap Sent:The ErrorString is :CALL_TRANSFERRED : REASON: Primary WAS Failure. No Backup WAS Provisioned. Error number = 87878. ANI=994555902585 DID=7000 TollFreeNum=8888 Reseller=GVPOwner Customer=Admin Application=BAKCELLIVRTEST SessionID={008B4E3A-E7E7-1003-A2BA-AC1D000EAA77} LastError=NETWORK_ERROR LastErrorString=Server Error  ErrorURL: http://172.29.0.9:8082/BAKCELLIVR/vxml/start.jsp?NEXTACTION=START&ANI=994555902585&DID=8888&SESSIONID={008B4E3A-E7E7-1003-A2BA-AC1D000EAA77}: CCThread:Inbound PortNumber:7021
[2012/07/16 10:07:38.528] 201FA GenericGlobalData.cpp:262 C=34:L=2:U=0 sendTrap(): GenericParser makeIAction, could not find make function for action
[2012/07/16 10:07:38.530] 201FA GenericParser.cpp:57 C=35:L=1:U=0 makeIAction could not find make function for action requesttimeout
[2012/0
[/code]

This is PopGateway's logfile. Log of catalina is empty
Title: Re: Assigning java function output to VXML variable in GVP 7.6
Post by: René on July 16, 2012, 12:02:52 PM
Does the START.jsp page open from browser? Can you send me generated VXML code?

R.
Title: Re: Assigning java function output to VXML variable in GVP 7.6
Post by: deadmeat on July 18, 2012, 11:01:29 AM
No, browser can not open the page.
[code]
HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 10 in the jsp file: /vxml/start.jsp
Timestamp cannot be resolved to a type
7:    <%@taglib prefix="debug" uri="/WEB-INF/tlds/debug"%>
8:
9: <%
10: java.sql.Timestamp timestamp = new Timestamp(System.currentTimeMillis());
11: pageContext.setAttribute("timestamp ", timestamp);
12: System.out.println(timestamp);
13: %>


Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:423)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:317)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:282)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


note The full stack trace of the root cause is available in the Apache Tomcat/6.0.18 logs.


--------------------------------------------------------------------------------

Apache Tomcat/6.0.18
[/code]
Title: Re: Assigning java function output to VXML variable in GVP 7.6
Post by: deadmeat on July 18, 2012, 11:44:27 AM
Well, I noticed that all efforts to assign value to VXML variable using <assign name="IVRTenter" value="<%=%>"/> are ending with server error. Must be the specifications of VXML it can only accept static values in value="" expression, not the server code like <% %> :-(
That's why I used <c:set > instead. But it doesn't put any value to variable, it remains empty.  This construction <%
java.sql.Timestamp timestamp = new Timestamp(System.currentTimeMillis());
pageContext.setAttribute("timestamp ", timestamp);
System.out.println(timestamp);
%> is working fine, I see it in catalina.out (the println function) the problem is to assign this output to VXML variable. Somebody has any thoughts on that ?
Title: Re: Assigning java function output to VXML variable in GVP 7.6
Post by: René on July 18, 2012, 12:18:18 PM
Hi deadmeat,

Construction <%= ... %> is never passed to VoiceXML interpreter as it is processed by your Java server.

Your problem is related to the fact that your Java server doesn't know 'Timestamp' type (class). Please fix this error first.

[quote]An error occurred at line: 10 in the jsp file: /vxml/start.jsp
[color=red]Timestamp cannot be resolved to a type[/color]
7:    <%@taglib prefix="debug" uri="/WEB-INF/tlds/debug"%>
8:
9: <%
10: java.sql.Timestamp timestamp = new Timestamp(System.currentTimeMillis());
11: pageContext.setAttribute("timestamp ", timestamp);
12: System.out.println(timestamp);
13: %>[/quote]

R.
Title: Re: Assigning java function output to VXML variable in GVP 7.6
Post by: deadmeat on July 18, 2012, 12:52:04 PM
Well, thanks for your help guys. I finally made it work. Here is the proper code:
[code]
<?xml version="1.0" encoding="UTF-8"?><%@page contentType="text/xml" pageEncoding="UTF-8" buffer="none"%>
<vxml xmlns="http://www.w3.org/2001/vxml"  xml:lang="ru-RU" version="2.0" application="root.jsp">
    <%@page import="java.util.*" %>
    <%@taglib prefix="bakcellivr" uri="/WEB-INF/tlds/bakcellivr"%>
    <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
    <%@taglib prefix="ad" tagdir="/WEB-INF/tags/attach_data"%>
    <%@taglib prefix="debug" uri="/WEB-INF/tlds/debug"%>

<%
Long timestamp = (Calendar.getInstance()).getTimeInMillis();
pageContext.setAttribute("timestamp", timestamp);
System.out.println(timestamp);
%>

    <form>
        <!-- Get the attach data -->
        <ad:get name="attach_data">
            <param name="LANGUAGE" value=""/>
            <param name="SERVICE_TYPE" value=""/>
            <param name="CUSTOMER_TYPE" value=""/>
            <param name="CUSTOMER_VALUE" value=""/>
            <param name="WB_INDICATOR" value=""/>
            <param name="SERVICE_ID" value=""/>
            <param name="SUBTREE_ID" value=""/>
            <param name="MENU_ID" value=""/>
            <param name="SERVED_ANI" value=""/>
            <param name="IVR_BACK" value=""/>
            <param name="RP_LEVEL_1_TARGET" value=""/>
            <param name="MENU_PARENT" value=""/>
            <param name="MENU_ACTION" value=""/>
            <param name="MENU_TARGET" value=""/>
        </ad:get>

        <block>

            <assign name="OBMESSAGE" expr="${bakcellivr:getIvrOption('obmessage')}"/>
            <assign name="IVRTENTER" expr="${timestamp}"/>
   
            <if cond="attach_data.LANGUAGE != undefined">
                <assign name="LANGUAGE" expr="attach_data.LANGUAGE"/>
            </if>
            <if cond="attach_data.SERVICE_ID != undefined">
                <assign name="SERVICE_ID" expr="attach_data.SERVICE_ID"/>
            </if>
            <if cond="attach_data.SUBTREE_ID != undefined">
                <assign name="SUBTREE_ID" expr="attach_data.SUBTREE_ID"/>
            </if>
            <if cond="attach_data.MENU_ID != undefined">
                <assign name="MENU_ID" expr="attach_data.MENU_ID"/>
            </if>
            <if cond="attach_data.SERVICE_TYPE != undefined">
                <assign name="SERVICE_TYPE" expr="attach_data.SERVICE_TYPE"/>
            </if>
            <if cond="attach_data.CUSTOMER_TYPE != undefined">
                <assign name="CUSTOMER_TYPE" expr="attach_data.CUSTOMER_TYPE"/>
            </if>
            <if cond="attach_data.CUSTOMER_VALUE != undefined">
                <assign name="CUSTOMER_VALUE" expr="attach_data.CUSTOMER_VALUE"/>
            </if>
            <if cond="attach_data.WB_INDICATOR != undefined">
                <assign name="WB_INDICATOR" expr="attach_data.WB_INDICATOR"/>
            </if>     
            <if cond="attach_data.SERVED_ANI != undefined">
                <assign name="SERVED_ANI" expr="attach_data.SERVED_ANI"/>
            </if>

            <if cond="attach_data.IVR_BACK != undefined">
                <assign name="IVR_BACK" expr="attach_data.IVR_BACK"/>
            </if>

            <if cond="attach_data.MENU_PARENT != undefined">
                <assign name="MENU_PARENT" expr="attach_data.MENU_PARENT"/>
            </if>

            <if cond="attach_data.MENU_ACTION != undefined">
                <assign name="MENU_ACTION" expr="attach_data.MENU_ACTION"/>
            </if>
            <if cond="attach_data.MENU_TARGET != undefined">
                <assign name="MENU_TARGET" expr="attach_data.MENU_TARGET"/>
            </if>

            <if cond="attach_data.RP_LEVEL_1_TARGET != undefined">
                <assign name="RP_LEVEL_1_TARGET" expr="attach_data.RP_LEVEL_1_TARGET"/>
            </if>

            <debug:message message="start.jsp. ANI: ${param.ANI}"/>
            <debug:message message="start.jsp. DNIS: ${param.DNIS}"/>

            <!-- AV: VAR TEST -->
            <assign name="CONNID" expr="session.genesys.sessionid"/>

            <submit next="session.jsp" namelist="IVRTENTER CONNID ANI DNIS LANGUAGE CUSTOMER_TYPE CUSTOMER_VALUE SERVICE_TYPE WB_INDICATOR OBMESSAGE SERVICE_ID SUBTREE_ID MENU_ID RP_LEVEL_1_TARGET AGENT_LEVEL_1_TARGET IVR_BACK MENU_PARENT MENU_ACTION MENU_TARGET"/>
     
        </block>
    </form>
</vxml>
[/code]
Title: Re: Assigning java function output to VXML variable in GVP 7.6
Post by: deadmeat on July 18, 2012, 12:55:17 PM
By the way, when I was getting the timestamp like this: 2012-07-18 17:08:00.563 PopGateway was throwing errors, that this value cannot be assigned to a variable. Maybe some VXML restrictions, I don't know.