Create a Web service that permits users to send short text messages to other users and receive messages from other users. The Web service is termed asynchronous because messages are not received as soon as they are sent; users decide when they want to receive messages.
When a user logs in with a name and password, the Web service authenticates him by searching a database table. If the user is accepted, a unique ID number is created and sent to the user. The Web service uses this ID number to identify the user in all subse- quent calls to Web methods.
A user sends a message by calling a Web service method and passing a user ID, the name of the recipient, and the message text. A user receives her messages by passing a user ID to a Web method that returns an array of message strings.
When the user logs out, the unique ID assigned to the user is discarded. Here are the suggested method declarations:
'Logs into the message service with a username and password.
'Returns a unique integer to be used in subsequent transmissions.
Public Function Login(ByVal user As String,
ByVal passwd As String) As Integer
'Sends a message to a specific user. Parameters:
'userId: unique identifier returned by Login method.
'recipient: username of the receiver of the message
'msg: the text of the message
'Returns True if the userId is recognized, or False if it is not.
Public Function Send(ByVal userId As Integer,
ByVal recipient As String,
ByVal msg As String) As Boolean
'Gets all messages addressed to the current user.
'If the userId is recognized, an Array of String containing
'the messages is returned; otherwise, an empty array is returned.
Public Function GetMessages(ByVal userId As Integer) As String
'Logs out of the mail service. Discards the unique user ID.
Public Sub Logout(ByVal userId As Integer)