【发布时间】:2014-12-30 04:06:00
【问题描述】:
对于我的一生,我无法弄清楚为什么我会收到 Twilio 响应对象的操作 URL 的 XML 解析错误。我已经附上了输出页面错误和用于生成 XML 的 java 代码。
输出错误
XML Parsing Error: not well-formed
Location: https://test.ignore.com/ApplicationName/go.acx?action=ivr.outbound.twilio.Introduction&rkey=1
Line Number 4, Column 101:<Response><Gather action="instanceurl.com/AccessWorx/go.acx?action=ivr.outbound.twilio.Selection&rkey=1" timeout="5" numDigits="1" finishOnKey="#" method="GET"><Say>This is an automated message from __________ to notify you of a service issue.Here is a sample message. Press 1 to accept this serviceissue, Press 2 to forward this call to the next contact in you company, press 3 if you are not the correct person to contact, press 4 to repeat these options.</Say></Gather></Response>
----------------------------------------------------------------------------------------------------^
^ 与上述代码格式不匹配,但它本质上指向操作 url 末尾的 rkey=1 中的“=”符号。
JAVA 代码
StringBuffer sb = new StringBuffer();
sb.append("This is an automated message from ___________ to notify you of a service issue.")
.append(serviceMessage)
.append("Press 1 to accept this service"
+ "issue, Press 2 to forward this call to the next contact in you company, press 3 "
+ "if you are not the correct person to contact, press 4 to repeat these options.");
// Create a TwiML response and add our friendly message.
TwiMLResponse twiml = new TwiMLResponse();
Say say = new Say(sb.toString());
Gather g = new Gather();
// set url to selection with paramter for rkey
IVRAgent ivrAgent = new IVRAgent();
g.setAction(ivrAgent.buildActionUrl(callBean.getInstanceUrl() + "go.acx?", "ivr.outbound.twilio.Selection", rkey.toString()));
g.setTimeout(TIMEOUT);
g.setNumDigits(1);
g.setFinishOnKey(POUND);
g.setMethod("GET");
try {
g.append(say);
twiml.append(g);
} catch (TwiMLException e) {
log.error("Error in creating twiml", e);
e.printStackTrace();
}
【问题讨论】:
-
查看stackoverflow.com/questions/1328538/…。尝试转义
&char。 -
谢谢 Bhesh ... 原来你是对的!发布问题似乎会立即引导您找到自己的答案。
-
是的。如果阅读链接中的答案,您也可以从那里的海报中看到类似的体验。 :)