Avatar of Uniqueinc

asked on 

Using SOAP: Object reference not set to an instance of an object.

First, I am a novice to programming.  This is my first time creating a webpage.

I am creating a simple web page that will reference some SOAP commands from a web service.  The page will have a button that when clicked will call a SOAP command write some data to a table in a SQL DB.  However, it is getting an "Object reference not set to an instance of an object." error when it tries to the command.  I put in a breakpoint to find out where the error is happening and it happens during the p.PunchIn command.  I tried to put in a breakpoint in my Reference.vb, but the breakpoint wasn't working there.

I'm thinking that my aspx is still not calling up the PunchIn code correctly.  Is that right or am I'm looking in the wrong direction?
'''Here is the aspx.vb code:
Imports TimePunchWeb.Punch
Imports Microsoft.VisualBasic.Devices
Public Class _Default
    Inherits System.Web.UI.Page
    Dim p As Punch.Punch
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Request.Cookies("userInfo") Is Nothing Then
            Employee_Number_Box.Text = Server.HtmlEncode(Request.Cookies("userInfo")("EmpNumber"))
        End If
    End Sub
    Protected Sub Punch_In_Btn_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Punch_In_Btn.Click
            lblMessage.Text = ""
            p.PunchIn(Employee_Number_Box.Text, Now.ToShortDateString, Now.ToString, PunchType.Punch.ToString)
            lblMessage.Text = "Success"
        Catch ex As Exception
            lblMessage.Text = "Error punching in: " & ex.Message
        End Try
    End Sub
    Private Sub SaveUserIDAsCookie()
        Response.Cookies("userInfo")("EmpNumber") = Employee_Number_Box.Text
        Response.Cookies("userInfo")("lastVisit") = DateTime.Now.ToString
        Response.Cookies("userInfo").Expires = DateTime.Now.AddDays(365)
    End Sub
''''Here is the fucntion from the SOAP/webservice:
Public Function PunchIn(ByVal EmployeeID As String, ByVal PunchDate As String, ByVal TimeIn As String, ByVal PunchType As String) As String
            Dim results() As Object = Me.Invoke("PunchIn", New Object() {EmployeeID, PunchDate, TimeIn, PunchType})
            Return CType(results(0),String)
        End Function

Open in new window

Web Languages and StandardsWeb ApplicationsASP.NET

Avatar of undefined
Last Comment

8/22/2022 - Mon