SMS Based Trading Portal For Sri Lankan Farmers and Traders This thesis was submitted to the Department of Computer Science and Engineering of the University of Moratuwa in partial fulfillment of the requirements of the Degree of M.Sc. in Computer Science Specializing in Software Architecture By A.M Samitha Amarapathy Department of Computer Science and Engineering University of Moratuwa Sri Lanka December 2007 ii Declaration I, A.M Samitha Amarapathy hereby declare that the work included in this dissertation in part or whole has not been submitted for any other academic qualification at any institution. A.M Samitha Amarapathy Dr. Prasad Jayaweera Supervisor iii Abstract In Sri Lanka, at present farmers are not getting competitive prices for their agricultural products as they are being exploited at the hands of a hierarchy of middlemen. They are also not acquainted with the modern technology to get timely and accurate market information on agricultural commodities. Further an efficient mechanism does not exist for framers in remote areas and traders to negotiate on trading deals as well as for payment processing. This research focuses on implementing a cost effective solution based on SMS messages that enable farmers to gain a higher profit margin for their crops by directly liaising with the buyers for the sale of products at completive prices in agro trading. This research proposes the development of SMS Based Trading Portal with the support of a web client that aims to assist some administrative operations and user queries. The proposed system is based on a typical stock trading system where the farmer advertises his products and trader then directly negotiate with farmer through biding mechanism to achieve competitive advantage on either side. To facilitate the provision of an end to end comprehensive solution to addresses issues in agro trading, the system is also equipped with an efficient automated mechanism for payment processing and order transportation. Further more the system eventually interacts with stakeholders through automated alert service. It also exposes a web service as an integration point for third parties to interact with the system. As per the test results system has demonstrated a good response time for all user queries maintaining a high accuracy in the responses when there was a reasonable data load. The automated farmer- trader offer matching and notification generation service proved to be well operating and the bidding process is well streamlined with the business requirement ultimately leading to automated fund transfer with high accuracy. iv Acknowledgements First, I would like to thank my supervisor Dr. Prasad Jayaweera whose excellent supervision and invaluable suggestions enabled me to complete this project successfully. Closely behind is my co-supervisor Mr. Puvanendran Senthilruban who rendered an enormous support in providing technical supervision in implementing the concept of SMS based agro trading . Dr. Sanath Jayasena, MSc Coordinator/Head of the Dept. of Computer Science & Engineering needs to be especially acknowledged for his support both at an administrative level and as a mentor. I must be grateful to Dr. Gihan Dias for providing guidelines for finding a good research project as well as for especially directing me towards SMS based agro trading which generated the enthusiasm to engage with the current implementation. I would like to thank Ms. Vishaka Nanayakkara for conducting the subject research seminar with as well as for the enthusiasm shown in finding the most suited supervisor for my project. Also my sincere thanks go to Prof. Dileeka Dias from the electronics department for her support in obtaining a GSM Modem for testing purposes. Rohitha, my colleague in the same batch who introduced me to Mr. Dinesh Saparamadhu at hSenid is also acknowledged with gratitude. I must be grateful to Mr Dinesh for allocating Mr. Senthil as my co-supervisor as well. My sincere thanks go to Thanya ,Nishan ,Padman,Sandhakal,Manjula and Misnad for supporting me in various ways and Vijitha for lending me his mobile phone for testing. Finally I would like to thank my loving wife for bearing with me for the entire duration of this engagement with patience. v Table of Contents Abstract .............................................................................................................................. iii Acknowledgements............................................................................................................ iv Table of Contents................................................................................................................ v List of Figures .................................................................................................................. viii List of Tables ...................................................................................................................... x 1. Introduction..................................................................................................................... 1 1.1 Background............................................................................................................... 1 1.1.1 Need of an e-business platform for Sri Lankan agriculture market............ 1 1.1.2 What Form of e-business platform would serve the purpose ............................ 2 1.2 Research Goals.......................................................................................................... 3 1.3 Scope......................................................................................................................... 4 1.4 My Contribution to the Research Work done ........................................................... 6 2. Literature Review............................................................................................................ 7 2.1 Related work on electronic agricultural commodity trading .................................... 7 2.2 Review on the trading framework based on ebXML and UMM............................ 14 3. Methodology & Approach ............................................................................................ 20 3.1 Problem Identification ............................................................................................ 20 3.2 Survey On Possible Technological Approaches and Trading Frameworks............ 22 3.2.1 .NET Mobile Application with WML Client............................................ 22 3.2.2 JAVA Mobile Application with WML Client .......................................... 23 3.2.3 J2ME Application ..................................................................................... 23 3.2.4 SMS Based Approach with Web Client.................................................... 26 3.2.5 PC based Web Solution ............................................................................ 28 3.2.6 SIM Application Toolkit (SAT)................................................................ 28 3.2.6 Survey On SMS Gateways and SMS Libraries ........................................ 29 3.2.7 Survey on Trading Framework ................................................................. 29 3.3 Evaluation among the possible technologies identified.......................................... 29 3.4 Approach to Construct the Solution........................................................................ 32 3.4.1 Define the Trading Framework........................................................................ 32 3.4.2 Business Process Modeling with UML ........................................................... 34 3.4.3 Define High level Architecture and Design Components................................ 35 3.4.4 Define SMS messaging Protocols and Mapping messaging codes and system modules ..................................................................................................................... 36 3.5 Evaluation to Claim the Suitability of the Solution ................................................ 36 vi 4. Design and Implementation .......................................................................................... 37 4.1 Business Process Modeling..................................................................................... 37 4.1.1 Requirement Artifacts ...................................................................................... 37 4.1.2 Analysis artifacts.............................................................................................. 38 4.1.3 Design Artifacts ............................................................................................... 40 4.2 System Implementation ......................................................................................... 49 4.2.1 High Level Architectural Components ............................................................ 49 4.2.2 Implementation of SMS Gateway.................................................................... 51 4.2.3 SMS Message Series................................................................................. 52 4.3 Technical Implementation ................................................................................ 53 4.3.1 SMS Processing Module.................................................................................. 53 4.3.2 User Management ............................................................................................ 55 4.3.3 Offer Management Module.............................................................................. 57 4.3.4 Bid Management Module ................................................................................ 63 4.3.5 Payments Management Module....................................................................... 64 4.3.6 Transport Management .................................................................................. 67 4.3.7 Service Registration ......................................................................................... 68 4.3.8 Web Client – Components ............................................................................... 68 4.4 AgroTrading Web Service ...................................................................................... 69 4.5 Database Design.................................................................................................. 70 5. Test Results and Evaluation.......................................................................................... 71 5.1 Test Approach......................................................................................................... 71 5.2 Test Results Evaluation For Functional Requirements........................................... 72 5.2.1 User Management ............................................................................................ 72 5.2.2 Farmer Offer Management .............................................................................. 73 5.2.3 Trader Offer Management ............................................................................... 74 5.2.4 Farmer –Trader Offer Matching ...................................................................... 74 5.2.5 Farmer Queries................................................................................................. 75 5.2.6 Trader Queries ................................................................................................. 75 5.2.7 Trader placing a Bid for a specific farmer offer .............................................. 76 5.2.8 Farmer’s Negotiation on the Bid Amount ..................................................... 77 5.2.8 Search for Best Bid .......................................................................................... 77 5.2.9 Locking an Offer in Negotiation...................................................................... 77 5.2.10 Bid Closure and Acceptance.......................................................................... 78 5.2.11 Payments Management .................................................................................. 79 5.2.12 Transportation Management .......................................................................... 80 5.2.13 Service Registration ....................................................................................... 81 5.3 Systems Capability in meeting Non-Functional Requirements .............................. 82 5.4 Approach for empirical evaluation of the system................................................... 82 5.5 Questioner based user evaluation of the system ..................................................... 83 vii 6. Enhancements to the Trading Portal ............................................................................. 87 6.1 Some of the limitations with the current System.................................................... 87 6.1.1 Technical Limitations ...................................................................................... 87 6.1.1 Operational Limitations ................................................................................... 87 6.2 Profile Management................................................................................................ 88 6.2.1 Achieving ebXML compliancy with Profile Manager .................................... 88 6.2.2 Operational aspects of Profile Manager........................................................... 89 7. Conclusions and Future Work ...................................................................................... 93 7.1 Conclusions............................................................................................................. 93 7.2 Recommendations................................................................................................... 94 7.3 Future Work ........................................................................................................... 95 8. References..................................................................................................................... 97 Appendix A..................................................................................................................... 100 Appendix B ..................................................................................................................... 101 Appendix C ..................................................................................................................... 103 Appendix D..................................................................................................................... 112 Appendix E ..................................................................................................................... 120 viii List of Figures Figure 1 - Design time and runtime artifacts of the proposed frame work Figure 2 - Phases of a Business Collaboration from the ISO Open-edi Model ( [16]) Figure 3 - Outline of Methodology Followed Figure 4 - High-level Architecture for .NET Mobile Application Figure 5 - High-level Architecture for J2ME Approach Figure 6 - High-level Architecture for SMS based Application Figure 7 - Three Tier Architecture employed for the Trading Portal Figure 8 - High Level Use case Diagram for the Trading Portal Figure 9 - Sequence Diagram - Farmer Advertising an Offer Figure 10 - Sequence Diagram - Trader Placing a Bid Figure 11 - Sequence Diagram -Matching Farmer –Trader Offers and Generating Notifications Figure 12 - Sequence Diagram -Sending System generated SMS to Subscribers Figure 13 - Overview Business Process Use Case Figure 14 - Farmer –Trader Offer Matching Business Collaboration Protocol Figure 15 - Farmer –Trader Bid Acceptance Collaboration Protocol Figure 16 - Contract Offer Transaction Pattern Figure 17 - Contract Accept/Reject Transaction Pattern Figure 18 - TP for Contract Negotiation: Contract-Request Figure 19 - Contract Establishment CP Figure 21 - High Level Design Components Figure 22 - Implementing the SMS Gateway Figure 23 - Flow Of SMS in the System Figure 24 - User Registration Process Figure 25 - Farmer -Trader Offer Management Figure 26 - Funds Transfer Automation Process Figure 27 - User registration Web Client Figure 28 - User registration Confirmation SMS Figure 29 - SMS for Farmer Advertising Offer to Sell Figure 30 - Acceptance SMS for Farmer’s Offer to Sell Figure 31 - SMS for Trader Posting an Offer to Buy Figure 32 - Acceptance SMS for Traders ’s Offer to Sell Figure 33 - Exact Match notification to Traders Figure 34 - Exact Match notification to Farmer Figure 35 - Farmer –Trader Offer analysis web interface Figure 36 - Product search web interface Figure 37 - Successful Bid Placement Notification for Trader Figure 38 - Notification on the bid for Farmer Figure 39 - Notification on Best Bid for farmer offer Figure 40 - Notification on Bid Locking to farmer Figure 41 - Systems Notification on farmer’s bid closure suggestion to trader Figure 42 - Systems Notification on Traders bid closure confirmation ix Figure 43 - Systems Notification on initiation on payments handling Figure 44 - Notification on Successful funds transfer to Farmer Figure 45 - Notification on Successful funds transfer to Trader Figure 46. A Prototypic illustration of the Profile Management Module Figure 47. Business Intelligence Engine to analyze history Figure 48 - Web Client Login Page Figure 49. A Brochure Designed to Facilitate Farmers in SMS operations x List of Tables Table 1 - Message Series and corresponding System Functionality Table 2 - User Management Module – Message Codes Table 3 - Farmer to System Messages in Farmer Offer Management Table 4 - Matching Criteria’s for commodity (product ) search Table 5 Trader to System Messages in TraderOffer Management Table 6 - Farmer & Trader to System Messages in BID Management Table 7 - Farmer & Trader to System Messages in Payments Management Table 8 - Trader & Transporter to System Messages in Transportation Management Table 9 - Trader & Transporter to System Messages in Service Registration Table 10 : Summary of questioner based user evaluation of the system Table 11 : Quality assurance test cases planed to test the system functionality Table 12 : Quality assurance test cases planed to test the system functionality Table 13 : Quality assurance test cases planed to test the system functionality Table 14 : Quality assurance test cases planed to test the system functionality Table 15 : Quality assurance test cases planed to test the system functionality Table 16 : Quality assurance test cases planed to test the system functionality Table 17 : Quality assurance test cases planed to test the system functionality Table 18 : Quality assurance test cases planed to test the system functionality