zoukankan      html  css  js  c++  java
  • FreeSwitch通过远程接口返回IVR控制流程

    学习杜老大的 用FreeSWITCH实现IVR

    http://www.freeswitch.org.cn/blog/past/2010/3/21/yong-freeswitchshi-xian-ivr/

    在我测试的时候,通过命令FS> originate user/1001 &ivr(welcome)没有问题,但是通过sip客户端拨号,就听不到导航音

    后来请教别人,发现在用户信息配置里面的user_context是default(<variable name="user_context" value="default"/>),但是杜老大的文章里面,介绍的配置却在public下面(一般来说,来话会先到达public dialplan,所以,你可以在conf/dialplan/public.xml中加入一个extension)

    问题就出在这个地方,我把用户信息配置里面的user_context改成public,成功了!

    下一步,就是在xml_curl.conf.xml 里面,读取远程的IVR控制流程

    2012/8/2

    今天终于把读取远程IVR控制流程,也试通了。之前一下呼不出去,返回“No Route, Aborting”。刚才又把各个XML脚本看了一遍,发现了问题所在。

    1、来是把xml_curl.conf.xml中diaplan的bindings写错了,这个diaplan是复制directory的,所以bindings就没有改。

    之前不成功的

    <binding name="dialplan">
    <param name="gateway-url" value="http://localhost:12569/Ivr.ashx" bindings="directory"/>
    </binding>

    修改后,成功的

    <configuration name="xml_curl.conf" description="cURL XML Gateway">
      <bindings>
     <!-- <binding name="directory">
          <param name="gateway-url" value="http://localhost:12569/Fs.ashx" bindings="directory"/>
        </binding> -->
     <binding name="dialplan">
      <param name="gateway-url" value="http://localhost:12569/Ivr.ashx" bindings="dialplan"/>
     </binding>
      </bindings>
    </configuration>

    2、Ivr.ashx里面的输出xml写的也不对,刚才又参考了杜老大的万能脚本那篇文章,写了一下。成功的脚本如下

    using System.Web;

    namespace Web
    {
        /// <summary>
        /// Ivr 的摘要说明
        /// </summary>
        public class Ivr : IHttpHandler
        {

            public void ProcessRequest(HttpContext context)
            {
                context.Response.ContentType = "text/plain";
                context.Response.Write(OutPut());
            }

            public bool IsReusable
            {
                get
                {
                    return false;
                }
            }

            public string OutPut()
            {
                var sFs = "<document type=\"freeswitch/xml\">";
                sFs = sFs + "<section name=\"dialplan\">";
                sFs = sFs + "<context name=\"default\">";
                sFs = sFs + "<extension name=\"incoming_call\">";
                sFs = sFs + "<condition field=\"destination_number\" expression=\"1000\">";
                sFs = sFs + "<action application=\"answer\" data=\"\"/>";
                sFs = sFs + "<action application=\"sleep\" data=\"1000\"/>";
                sFs = sFs + "<action application=\"ivr\" data=\"welcome\"/>";
                sFs = sFs + "</condition>";
                sFs = sFs + "</extension>";
                sFs = sFs + "</context>";
                sFs = sFs + "</section>";
                sFs = sFs + "</document>";

                return sFs;
            }
        }
    }

    总结:看来远程返回的脚本,都是要用下面这种格式的。

    <document type="freeswitch/xml">
    <section name="dialplan">
    </section>
    </document>

  • 相关阅读:
    java (取文本中间)字符串之间的文本
    Mysql数据库中text还是不够
    java读取网页内容
    controller to controller
    农历类
    java.lang.RuntimeException: com.google.inject.CreationException: Unable to create injector, see the following errors
    Java中List集合去除重复数据的方法
    idea启动tomcat的中文乱码问题
    idea局域网调试 can accept external connection不可勾选
    Mysql JDBC Url参数说明useUnicode=true&characterEncoding=UTF-8
  • 原文地址:https://www.cnblogs.com/chendaoyin/p/2615723.html
Copyright © 2011-2022 走看看