Calling External Web Services

In Dynamics NAV, you can use the Windows Communication Foundation, which provides a set of reliable objects for calling web services to use with .NET Framework interoperability.


The following code example uses a proxy web service class and calls a Read method from the Dynamics NAV web service. To set up this example, you expose page 42 as a web service in the Web Service table and then generate and compile the proxy class. For more information, see Working with Web Services in the MSDN Library.

The example requires the following variables.

Variable name DataType SubType Length
navBinding DotNet 'System.ServiceModel, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.ServiceModel.BasicHttpBinding
address text 256
salesOrderService DotNet 'SalesOrderService, Version=, Culture=neutral, PublicKeyToken=null'.NAV.SalesOrderService.SalesOrder_PortClient
endpointAddress DotNet 'System.ServiceModel, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.ServiceModel.EndpointAddress
salesOrder DotNet 'SalesOrderService, Version=, Culture=neutral, PublicKeyToken=null'.NAV.SalesOrderService.SalesOrder
navBinding := navBinding.BasicHttpBinding;  

// Set security mode to BasicHttpSecurityMode.TransportCredentialOnly  
navBinding.Security.Mode := 4;   
address :=   

// Set client credential type to HttpClientCredentialType.Windows  
navBinding.Security.Transport.ClientCredentialType := 4;  
salesOrderService := salesOrderService.SalesOrder_PortClient(navBinding,  

// Set impersonation level to System.Security.Principal.TokenImpersonationLevel.Delegation  
salesOrderService.ClientCredentials.Windows.AllowedImpersonationLevel := 4;  

// Include the sales order ID to be read.  
salesOrder := salesOrderService.Read('10000');