Success! At Last! Hope its not too late for the rest of the class though!
The first step is to create a web service. The following zip files will walk you through the process of creating web service.
Web Service Zip Files
The web service example that I have basically accepts 2 string paramaters and then picks up a third parameter from a table in the database i.e. the database in Hogwarts contains a table which has three fields username, password and name. The web service accepts the username and password and if they are present it will return the corresponding name .
The code of the web service is given below. However, before consuming thisweb service, kindly go through the tutorial in the above zip files. ALL THE CODE IS WRITTEN IN VB.NET. IN CASE YOU HAVE PROBLEMS PERFORMING THE CONVERSION, KINDLY ASK ME.
Imports System.Web.Services
Imports System.Data
Imports System.Data.SqlClient
_
Public Class Service1
Inherits System.Web.Services.WebService
' WEB SERVICE EXAMPLE
' The HelloWorld() example service returns the string Hello World.
' To build, uncomment the following lines then save and build the project.
' To test this web service, ensure that the .asmx file is the start page
' and press F5.
'
' _
'Public Function HelloWorld() As String
' Return "Hello World"
'End Function
Public Function getName(ByVal a As String, ByVal b As String) As String
Dim myConnection As SqlConnection
Dim myCommand As SqlCommand
Dim myReader As SqlDataReader
Dim SQL As String
Dim ConnStr As String
Dim name, name1 As String
SQL = "SELECT * FROM userpassword where user1 = '" & a & "' and password = '" & b & "'"
ConnStr = "server =hogwarts.cs.clemson.edu; uid = kchopra; pwd = jesus123; database =deptdb"
myConnection = New SqlConnection(ConnStr)
myConnection.Open()
myCommand = New System.Data.SqlClient.SqlCommand(SQL, myConnection)
myReader = myCommand.ExecuteReader()
If (myReader.Read()) Then
name1 = myReader.GetString(2)
name = "Welcome " & name1 & ". Congrats on being authenticated"
myConnection.Close()
Else
name = "Sorry, not authenticated"
myConnection.Close()
End If
Return name
End Function
End Class
Then, its time to consume this web service using a client on hogwarts. Click Next