This is using the web service in my previous post.  In Visual Studio I start by adding the web reference.  Select Project -> Add Service Reference

Then select Advanced…

Then Add Web Reference…

Where I insert URL encoded string for the published codeunit including the company name.

I created a form with a listbox object and a button.  I used this code to insert all employee no’s into the listbox.
[code htmlscript=”false” lang=”vb”]Public Class Form1
Dim ClockID As String
Dim Success As Boolean
Dim DefCred As Boolean
Dim ResponseMessage As String
‘The Web Service
Dim NAVPunch1 As New WebService.NAVPunch
‘New set of credentials
Dim User As New System.Net.NetworkCredential

Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
If DefCred Then
NAVPunch1.UseDefaultCredentials = True
NAVPunch1.Url = ""
Else
User.Domain = ""
User.UserName = ""
User.Password = ""
NAVPunch1.Credentials = User
NAVPunch1.Url = ""
End If
ClockID = "{4A212826-CAF3-4E3C-9D97-6923A692A209}"

End Sub
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Button1.Click
‘ Get Employee List
ResponseMessage = ""
ListBox1.Items.Clear()
Dim EmployeeList As New WebService.EmployeeList
Try
Success = NAVPunch1.GetClockEmployees(ClockID, _
EmployeeList, _
ResponseMessage)
CheckBox1.Checked = Success
TextBox1.Text = ResponseMessage
If Success Then
For Each Employee In EmployeeList.Employee
ListBox1.Items.Add(Employee.No)
Next
End If
Finally
End Try
End Sub
End Class[/code]

One thought on “Example on using NAV Web Service in Visual Studio vb.net

  1. Hey, Your page keeps redirects me. I press the back button and it keeps happening, I don’t know what is happening but thought you would like to be informed.

Leave a Reply

%d bloggers like this: