Consuming web services
Microsoft Dynamics NAV provides an easy interface to create web services, which allow us to expose the NAV data with business logic and proper authentication. Now, let's see how to use these web services.
How to do it...
Let's get started by creating a new codeunit from Object Designer.
Add the function name as
GetCustomer
.The function should take the following parameter:
Name
DataType
Length
CustNo
Code
20
Add the following local variable to the function:
Name
DataType
Subtype
Customer
Record
Customer
The function should return a text variable of length 50.
Add the following code to the function:
IF Customer.GET(CustNo) THEN EXIT(Customer.Name) ELSE EXIT('Not Found!');
Save and close the codeunit.
Search for the
Web Services
page inRoleTailored client
.In the
Web Services
page, chooseNew
.Create a new web service with our codeunit ID, and in the service name, enter
ConsumeWS
.Finally, mark the checkbox in the
Published
column.Create a new
Console Application...