<kColl id="sms"> <field id="encoding" value="UTF-8"/> <field id="requestHandler" value="com.ibm.btt.channel.sms.SMSRequestHandler"/> <field id="presentationHandler" value="com.ibm.btt.channel.sms.SMSPresentationHandler"/> <!-- channel policy configuration --> <field id="channelPolicyHandler" value="com.ibm.btt.test.MyChannelPolicyHandler"/> <field id="ruleService" value="javaCodeChannelRuleService"/> </kColl>
<com.ibm.btt.channel.sms.config.InboundHandlerConfiguration id="inbound1" xmlHttp="false" encoding="utf-8" presentationHandler="com.ibm.btt.test.ExtendPresentationHandler"> <com.ibm.btt.channel.sms.config.ParameterNames Injection="parameterNames" messageParamName="msgdata" fromParamName="sender" messageIDParamName="msgid" toParamName="receiver"/> <ref Injection="smsCommands" refId="SMSCommandTable"/> <ref Injection="replyMsgOutboundHandler" refId="outbound1"/> <map Injection="selfDefineParameters"> <entry key="messagetype" value="SMS:TEXT"></entry> </map> </com.ibm.btt.channel.sms.config.InboundHandlerConfiguration>
The default implementation class of SMS presentation handler is com.ibm.btt.channel.sms.SMSPresentationHandler, which returns empty string for the inbound http request. The SMS presentation handler is recommended to be configured in file btt.xml as the global presentation handler. If the inbound local presentation handler is set, it uses the local level; if the local is not set, it uses the global presentation handler; if neither is set, it throws exception DSENoRegisteredPresentationHandlerException.
package com.ibm.btt.test; import com.ibm.btt.base.DSEObjectNotFoundException; import com.ibm.btt.channel.sms.SMSHandlerConstant; import com.ibm.btt.channel.sms.SMSHandlerException; import com.ibm.btt.channel.sms.SMSPresentationHandler; import com.ibm.btt.channel.sms.config.InboundHandlerConfiguration; import com.ibm.btt.clientserver.ChannelContext; public class MovilgatePresentationHandler extends SMSPresentationHandler { @Override protected String getContent(ChannelContext channelContext) { StringBuilder sb=new StringBuilder(); InboundHandlerConfiguration config; try { config = (InboundHandlerConfiguration)channelContext.getRequestData() .getValueAt(SMSHandlerConstant.INBOUND_CONFIGID); sb.append(" "); sb.append("<MTResponse>"); sb.append("<IdTransaccion>"); sb.append((String) channelContext.getRequestData().getValueAt("data." + config.getParameterNames().getMessageIDParamName()) ); sb.append("</IdTransaccion>"); sb.append("<Id_Status>"); sb.append("0"); sb.append("</Id_Status>"); sb.append("<Status>"); sb.append("Transaccion exitosa"); sb.append("</Status>"); sb.append("</MTResponse>"); return sb.toString(); } catch (DSEObjectNotFoundException e) { throw new SMSHandlerException(e); } } }