Saturday, 30 April 2016

Exposing & Consuming the Web service from & inside Navision – Part-4

Continuing from my previous post. Find the link to access the same in case you missed it.

Exposing & Consuming the Web service from & inside Navision – Part-1

Exposing & Consuming the Web service from & inside Navision – Part-2

Exposing & Consuming the Web service from & inside Navision – Part-3

 

Step 5: Create a Codeunit to test Retrieve the data using above DLL and Send data in XML Format using another Web Service exposed in Dot Net.

How to create WCF Service Application using C#, Publishing it and creating DLL Class Library is out of scope of this document. You may require to take help from guy who are comfortable in .Net technology.

Let’s start with new codeunit, select the available ID in your database and suitable name to save this codeunit.

We will define a Global variable to hold the data we receive from Navision Web Service and pass to Web Service exposed outside Navision.

WebServiceUsage-16

Create a Function to Read/Export the data using Navision Web Service.

Variables defined to the function is also shown in below screen.

We will add the code similar to below. Description provided along with the code in below screenshot.

WebServiceUsage-17

Create a Function to Send Exported data from above function to the Web Service created outside the Navision. Web Service created in DotNet.

Here too we are using DLL file of the Outside Exposed Web Service.

Variables defined to the function is also shown in below screen.

We will add the code similar to below. Description provided along with the code in below screenshot.

WebServiceUsage-18

Now we have our both function ready.

One which Export data consuming the Navision Published Web Service and then read the data in BigText Variable and finally converted to Text variable.

Second one will send data consuming the Web Service Exposed outside Navision created in DotNet. 

Let us test our process if it works as desired.

We will call above both function.

When we call First Web Service as a result we get the XML format file data in my Global defined Text Variable.

We will review the data which we are going to send to Second Web Service on Screen for which we are simply calling the Message.

Finally we will send the data to the Second Web Service, the content of XML file stored in our Global Variable.

Code we use is as below shown screenshot.

WebServiceUsage-19

Save the codeunit and execute, as we have written our test code in Run trigger so we can directly run this codeunit.

The output will be as shown in below screenshots.

Until this step our Data is Exported and data is loaded in Global defined Text variable.

WebServiceUsage-20

Here the content of Text variable is shown in Message window, which we can verify the data which we are going to send to the external Web Service.

WebServiceUsage-21

As a final step we are sending this content to the External Web Service Exposed using DotNet.

WebServiceUsage-22

Verify the data received at the DotNet side. You can program the Second Web Service as save the content on disk as file or perform any processing like inserting those data in some other table or displayed on screen. 

That’s it for this series.

I will be posting couple of more posts on Web Services soon.

Since this was in response of request from one of my reader so I stick to the requirement.

In my other post I will show some different flavour of using the same.

Till then keep exploring and learning.

Will be back with other posts soon.

No comments:

Post a Comment