This service is only available during 9:00am - 20:00pm.
Install the SMS gateway server and do the configuration.
The knowledge about the SMS gateway is needed to develop the SMS solution according to the specific gateway. Use the SMS gateway named gateway A. The gateway is installed in machine 9.186.64.161 and the service port is 9501. Create a user test2 for the application.
Development using UDTT framework and UDTT SMS Handler
1 Create an enterprise application project named SMSEAR, create a dynamic web project named SMSWeb. Copy the bttchannels.jar, bttcore.jar, bttruleprovider.jar into the EAR project and add them to build path and J2EE dependency.
2 Right click the SMSWeb project, and select BTT Tools->Add BTT Nature. This step creates a default btt.xml file under the definitionfolder. Add the following code into the btt.xml:
3 Create the other UDTT definition files: format.xml, operation.xml, processor.xml, invoker.xml. The content can be left empty as the data in these definition files are not used here.
4 Create the following UDTT definition files with the sample code:
data.xml
<data.xml> <!-- Data collection for the branch context--> <kColl id="branchData" dynamic="true"> <field id="BranchId"/> <field id="REPLY_SMS_MSG"/> <iColl id="titles" size="2"> <kColl id="title"> <field id="name"/> <field id="value"/> </kColl> </iColl> </kColl> <!-- Data collection for the html session context--> <kColl id="sessionData"> </kColl> </data.xml>
context.xml
<context.xml> <!--root context--> <context id="branchServer" type="branch" parent="nil"> <refKColl refId="branchData"/> <refService alias="realCSServer" refId="realCSServer" type="cs"/> </context> <!-- The session context is created by the StartHtmlSession operation --> <!-- This context is dynamically chained to the root context by the operation --> <context id="htmlSessionCtx" type="session" parent="branchServer"> <refKColl refId="sessionData"/> </context>
1 Create a package named com.ibm.btt.test under src folder. Create the SMS Handler configuration XML file named SMSHandlerConfig.xml in this folder. Add the following code into the SMSHandlerConfig.xml file:
if (getValueAt(SMSHandlerConstant.REPLYMSG)==""||getValueAt(SMSHandlerConstant.REPLYMSG)==null) setValueAt(SMSHandlerConstant.REPLYMSG, "==== Transfer Successfully!==== \n Recipient:" +getContext().getValueAt("nickName")+"\n Amount:"+getContext().getValueAt("amount") +"\n Balance: 9201.20"); } }
JavaCodeChannelRuleService.java
package com.ibm.btt.test; import java.util.Calendar; import java.util.Map; import com.ibm.btt.channel.PolicyResult; import com.ibm.btt.channel.ruleprovider.java.JavaCodeRuleProviderService; public class JavaCodeChannelRuleService extends JavaCodeRuleProviderService { public Map<String> checkRule(Map<String> params) { System.out.println("JavaCodeChannelRuleService: checking the channel rule..."); PolicyResult result = (PolicyResult) params.get("result"); ChannelPolicyData data = (ChannelPolicyData) params.get("data"); Calendar now = data.getNow(); int hours = now.get(Calendar.HOUR_OF_DAY); if (hours >= 20 || hours < 9) { result.reject(); String message = "The Internet Bank is just opening for 9:00-20:00, please try later.”; result.addToMessages(message); } System.out.println("JavaCodeChannelRuleService: the result message is:" + result.getMessages()); return null; } } </String></String>
MyChannelPolicyHandler.java
package com.ibm.btt.test; import java.util.Calendar; import java.util.HashMap; import java.util.Map; import com.ibm.btt.channel.AbstractChannelPolicy; import com.ibm.btt.channel.PolicyResult; import com.ibm.btt.clientserver.ChannelContext; public class MyChannelPolicyHandler extends AbstractChannelPolicy { private PolicyResult result; @Override protected Map<String> getInputParameter(ChannelContext ctx) { Map<String> input = new HashMap<String>(); result = new PolicyResult(); ChannelPolicyData data = new ChannelPolicyData(); data.setDeviceType(ctx.getDeviceType()); data.setNow(Calendar.getInstance()); input.put("data", data); input.put("result", result); return input; } @Override protected PolicyResult processResult(Map<String> resultMap) { return result; } } </String></String></String></String>
4 Deploy the solution and use mobile phone to do the test. Deploy the EAR to the WebShpere Application Server. Then use the mobile phone to send a transfer command to the SMS gateway number, such as:
FT user01 payee01 1200
After a while, the mobile will receive the reply message:
==== Transfer Successfully!==== Recipient: payee01 Amount:1200.0 Balance: 9201.20
If you send the message not during 9:00am - 20:00pm, then the mobile will receive the reply message:
SMS command is rejected by channel policy. Reason= The Internet Bank is just opening for 9:00-20:00, please try later.