INTRODUCTION:
OData web services are a new addition to Microsoft Dynamics NAV, complementing the SOAP web services that have been available since Microsoft Dynamics NAV 2009. Developers planning to create Microsoft Dynamics NAV web services may need to decide which type of web service is best suited for their needs. First, there are some absolute limitations:
SOAP – Simple Object Access Protocol
ODATA – Open Data Protocol
SOAP Web Services
SOAP web services allow full flexibility for building operation-centric services. They provide industry standard interoperability. Windows Communication Framework (WCF) has supported SOAP services since its initial release in .NET Framework 3.0, and .NET 4. The additional support and default bindings is to make it easier to build SOAP services using WCF.
The most common type of messaging pattern in SOAP is the Remote Procedure Call (RPC), where one network node (the client) sends a request message to another node (the server), and the server sends a response message to the client.
OData Web Services (RESTful Webservice)
OData helps to focus on the business logic while building RESTful APIs without having to worry about the various approaches to define request and response headers, status codes, HTTP methods, URL conventions, media types, payload formats, query options, etc. OData also provides guidance for tracking changes, defining functions/actions for reusable procedures, and sending asynchronous/batch requests.
OData RESTful APIs are easy to consume. The OData metadata, a machine-readable description of the data model of the APIs, enables the creation of powerful generic client proxies and tools. OData is less suites for applications that primarily RPC-oriented or which data operations are constrained to certain prescribed patterns.
OData supports Representational State Transfer (REST)-based data services which enable resources identified by using Uniform Resource Identifiers (URIs). It is defined in an abstract data model (EDM) to be published and edited by web clients within corporate networks and across the Internet using simple Hypertext Transfer Protocol (HTTP) messages. OData services are lightweight, with functionality often referenced directly in the URI. SOAP web services expose a WSDL document, OData web services expose an EDMX document containing metadata for all published web services.
The extensions to the Atom Publishing Protocol defined in the AtomPub extensions to the OData protocol describe how REST-based data services can enable resources, identified using URIs. And it is defined in an abstract data model (EDM), to be published and edited by web clients within corporate networks and across the Internet using simple HTTP messages.
In addition to the AtomPub format, the OData implementation in Microsoft Dynamics NAV supports the JSON format, a somewhat less verbose format that may perform better in low-bandwidth environments.
ENABLING SOAP AND ODATA WEB SERVICES IN NAV SERVER
In Standard NAV installation, the Web-services are not Activated by Default. So, follow the below procedure to activate the Web-service.
Open Microsoft Dynamics NAV Server -> Open the Instance which we want to publish the Web Service -> Click Edit -> Enable the check box for the required Web Service as Shown below.
STEPS TO PUBLISH SOAP WEB SERVICE IN NAV:
The following example illustrates creating a new XML port and Key in the data to Item table through CodeUnit using SOAP Web-service:
Create XML Port:
2.Add Item Export as Root element in the first row. Add the Item table and indent the row, then add required Item fields as shown below.
3.Set the XML properties, Directions (If Required) and Default Namespaces – YES as shown below.
Run the XML Port from CodeUnit:
Publish the Code unit in Web Services
2. Set the Object Type as Codeunit and the Object ID as 60013. And then set the ServiceName as WSDataItemImport. Select Publish – True (So, that SOAPURL is generated automatically. This is the URL to be used for testing). In here the OData URL is “Not Applicable”.
TESTING SOAP WEBSERVICE:
We can Test the Web-services through Testing tools in available in the Internet.
Testing the Web Service using Google Chrome Wizdler
Ensure Chrome is installed on your testing machine. To enable Chrome, go to Google Search and type “Wizdler”. Click “Add” to Chrome →Add Extension to enable Wizdler, then reopen the browser. Once Wizdler is added successfully, the icon will be enabled in your browser.
2.You will get an XML file structure which you can add or edit the XML files.
3. Once you edit the Xml file with required data, select the required ‘Operation’ and Click ‘GO’.
4. If the Operation is successful, it will insert the data into Item table or else it will throw error.
SUCCESS:
FAILURE:
STEPS TO PUBLISH ODATA WEB SERVICE IN NAV:
Check if the endpoint works:
Copy the OData URL to Internet Explorer and press enter. It will display the content as shown below.
Note: Please don’t use OData V4 URL
To View the Customer List Content in XML format, follow the below procedure.
Go to Browser Settings -> Internet Options -> Select Content ->Select Feeds Web Slices Settings.
Below Content shows that the End Point is working.
You must be logged in to post a comment.
WhatsApp us