通话TwiML应用程序意外结束:找不到元素“回应”的声明 [英] TwiML App unexpected end of call: Cannot find the declaration of element 'response'

查看:279
本文介绍了通话TwiML应用程序意外结束:找不到元素“回应”的声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建的<一个href=\"https://www.twilio.com/docs/api/twiml/?utm_source=stackoverflow&utm_medium=social&utm_campaign=stackdocsupdate\"相对=nofollow> TwiML 应用程序并设置语音请求URL网络部署ASP.NET MVC的aplication操作方法:的 http://voiceapp-001-site1.myasp.net/voice

I created TwiML application and set Voice request URL the web deployed ASP.NET-MVC aplication action method: http://voiceapp-001-site1.myasp.net/voice

此操作方法,当有人去上面贴的URL调用:

This action method is invoked when somebody goes to the URL posted above:

 public ActionResult Voice() {

            Response.ContentType = "text/xml";

            // put a phone number you've verified with Twilio to use as a caller ID number
            string callerId = Settings.TwilioNumber;

            // put your default Twilio Client name here, for when a phone number isn't given
            string number = "jenny";

            // get the phone number from the page request parameters, if given
            if (Request["PhoneNumber"] != null) {
                number = Request["PhoneNumber"];
            }

            // wrap the phone number or client name in the appropriate TwiML verb
            // by checking if the number given has only digits and format symbols
            string numberOrClient;
            var m = Regex.Match(number, @"^[\d\+\-\(\) ]+$");
            if (m.Success) {
                numberOrClient = string.Format("<Number>{0}</Number>", number);
            } else {
                numberOrClient = string.Format("<Client>{0}</Client>", number);
            }
            ViewBag.CallerId = callerId;
            ViewBag.NumberOfClient = numberOrClient;
            return View();
        }

语音观点如下:

<?xml version="1.0" encoding="UTF-8" ?>
<response>
    <dial callerid="@ViewBag.CallerId">
        @Html.Raw(ViewBag.NumberOfClient)
    </dial>
</response>

然后我尽量让测试呼叫:

Then I try to make test call:

但13秒通话自动终止后在错误日志中我得到:

but after 13 seconds call is automatically terminated and In the error log I get:

Notification SID NOe85ffe80dfc52e81f942a7414c9f7c9c
Warning 12200 Schema validation warning
Description Cannot find the declaration of element 'response'.

但低于身体部分,我可以看到的元素响应

推荐答案

喜Twilio开发布道者在这里。

Hi Twilio developer evangelist here.

您可以尝试修改你的观点,看起来像这样呢?

Can you try modifying your view to look like this instead?

<?xml version="1.0" encoding="UTF-8" ?>
<Response>
    <Dial callerId="@ViewBag.CallerId">
        @Html.Raw(ViewBag.NumberOfClient)
    </Dial>
</Response>

请记住XML是大小写敏感的,所以在你的XML标签的外壳实际上很重要。另外,我建议使用 Twilio.TwiML 助手库。就这样,你可以为你生成与右箱的XML,并完全避免错别字。

Remember XML is case-sensitive, so the casing in your XML tags actually matter. Also, I would suggest using the Twilio.TwiML helper library. With that, you can get your XML generated for you with the right casing, and avoiding typos altogether.

下面是你如何做到这一点:

Here's how you'd do it:

var twiml = new TwilioResponse();
var dialAttributes = new {callerId = "48326304351"};

var dial = twiml.Dial("+15555555555", dialAttributes);
return TwiML(dial);

这篇关于通话TwiML应用程序意外结束:找不到元素“回应”的声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆