Try
'======================================================
'common code
'======================================================
Dim companyKey As CompanyKey
Dim context As Context
' Create an instance of the service
Dim wsDynamicsGP As New DynamicsGPClient()
'add authentication
wsDynamicsGP.ClientCredentials.Windows.ClientCredential.Domain = "myDomain"
wsDynamicsGP.ClientCredentials.Windows.ClientCredential.UserName = "myUser"
wsDynamicsGP.ClientCredentials.Windows.ClientCredential.Password = "myPassword"
' Create a context with which to call the web service
context = New Context()
' Specify which company to use
companyKey = New CompanyKey()
companyKey.Id = (6)
' Set up the context
context.OrganizationKey = DirectCast(companyKey, OrganizationKey)
'======================================================
'get a list of customers
'======================================================
Dim customerCriteria As New CustomerCriteria()
'only get customers that start with 'a'
Dim oRestriction As New LikeRestrictionOfstring
oRestriction.From = "a"
oRestriction.To = "az"
customerCriteria.Id = oRestriction
' Retrieve the list of customers
Dim oCustomerSummary As CustomerSummary()
oCustomerSummary = wsDynamicsGP.GetCustomerList(customerCriteria, context)
'print them out
For Each v As CustomerSummary In oCustomerSummary
Debug.WriteLine(v.Name)
Next
' Close the service
If wsDynamicsGP.State <> CommunicationState.Faulted Then
wsDynamicsGP.Close()
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try