Professional Documents
Culture Documents
Code
Archive
Export to GitHub
mchoice-applications -
JavaGuide.wiki
Software Requirements:
JDK 1.6+
mChoice-Simulator-LATEST
Tomcat (or any server of your choice)
IDE of your choice
Step 3: Import the USSD API libraries which you have downloaded
Step 5: onMessage will be called when a USSD request comes from a mobile.
MchoiceUssdMessage is the only parameter passed to this onMessage method.
MchoiceUssdMessage has public methods; getAddress, getConversationId,
getCorrelationId, getMessage,
Step 6: onSessionTerminate method will be called when a conversation ends. This method
has one argument, MchoiceUssdTerminateMessage, which is mostly similar to
MchoiceUssdMessage.
Step 7: Once you receiver user message, write a logic class to process it.
Step 8: To reply back to the user, instantiate MchoiceUssdSender class. The constructor
takes 3 string arguments; those are Server URI, Application ID, and Password. When testing
with the simulator, this Server URI must be http://127.0.0.1:8000/ussd/.
Step 9: Call sendMessage to reply back to the user. See the following code extract. The lass
parameter is a Boolean. True means that from this message, the session will be terminated.
Step 10: Define this servlet in web.xml file. Add the following to xml elements.
<servlet-mapping>
<servlet-name>receiver</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
```
Step 11: Build the application and create the WAR file and deploy it on the server of your
choice.
Hint – When developing complex USSD application with many levels of submenus, have a
java.util.Map with the "Address" as the key. When a user request for service, check whether
this "Address" exist on the map. If not, send the user the main menu and add the "Address"
into the Map. In onSessionTerminate method, remove the "Address" from this map.
https://code.google.com/archive/p/mchoice-applications/wikis/JavaGuide.wiki 2/2