Web Services - Native Endpoint - How to pass credentials

So, I'm trying to connect to a remote install of Web Services for Dynamics GP and I get this:

The caller was not authenticated by the service.
The request for security token could not be satisfied because authentication failed.

Grrr.  

This article shows how to connect to Web Services for Dynamics GP and pass credentials. The example uses .NET code.

 

Related Articles

... and you 'll find more on the Web Services Menu

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

RealWorldCode gives developers practical, real‑world solutions with clean, working code — no fluff, no theory, just answers.
Links
Home
Knowledge Areas
Sitemap
Contact
Et cetera
Privacy Policy
Terms and Conditions
Cookie Preferences