Using an OData web service
As you previously learned, a page web service has also an OData URL.
Let's learn how to use OData web service by performing the following steps:
To use an OData web service, we need to reference it in our Visual Studio by going to the project name in Solution Explorer, right-clicking on it, and navigating to Add | Service Reference…:
In the Add Service Reference window, add the OData service URL at Â
http://servername:port/NAVInstance/OData/
.servername
is the name (or IP address) of your NAV server,port
is the OData web service port, andNAVInstance
is the name of your NAV instance.In this sample, our service URL is
http://VMEID31:7048/DynamicsNAV90/OData/
.Give a friendly namespace for the service (in this sample, we use
NAVODATA
):Now you can use the ODATA service in your application. First, add a reference to:
using System.Data.Services.Client;
Then set the ODATA service URL by reading it from your
app.config
file:string serviceUri = ...