Authorization, Base64 Convert, Business Central, InStream, Integration, JSON, JsonObject, JsonToken, OData, Post, Postman, SOAP, Tenant Media, Tip & Tricks, URL, Web Access Key, Web Services

Integrating with Business Central – using Web Service

This is fourth post in this series, if you wish to see first post, you can access here.

In second post I discussed about, how to create Azure Functions, you can access here.

In previous post I discussed about, how to Integrate Azure Functions in Business Central, you can access here.

In this post we will discuss how to make available QR Image using API by exposing as Web Service.

Let’s cut the theoretical part and coming directly to the solution.

This post is very short and as an answer to query from one of the blog readers, who regularly gives feedback and suggest topic he wish from me. Sometime it is not possible to write post for every query, but I try to pick some which I find interesting. Converting any topic into post is quite time taking, solution can be of 10 mins but presenting same in form of blog takes 2-3 hours, sometimes even more.

Some time appropriate environment is not available where I can put the solution and take screenshots to present as blog.

Since this topic is part of current series, I am writing posts on, so I was able to easily pick this topic.

Requirement is to add capability to get QR Image we generated in our previous posts using Web Service/ API/ OData/ JSON Base64Text.

To get this working we will first create a Codeunit with appropriate methods and expose it as Web Service.

Step – 1.

Create Codeunit & Add below method.

Step – 2

Publish above Codeunit as Web Service.

Step – 3

Copy SOAP URL

[SOAP URL]

https://api.businesscentral.dynamics.com/v2.0/1e4fc386-962e-4a20-8364-d5aeb65e2485/Test/WS/CRONUS%20USA%2C%20Inc./Codeunit/QRCodeGenerator

Convert to ODataV4 URL by making necessary modification as below:

[ODataV4 URL]

https://api.businesscentral.dynamics.com/v2.0/1e4fc386-962e-4a20-8364-d5aeb65e2485/Test/ODataV4/QRCodeGenerator

Similarly, your $metadata URL will be:

https://api.businesscentral.dynamics.com/v2.0/1e4fc386-962e-4a20-8364-d5aeb65e2485/Test/ODataV4/$metadata

Run the metadata URL in browser:

Search for your function created above, you should get definition as below:

<Action Name=”QRCodeGenerator_GetQRSetImageAsJSON”>

<Parameter Name=”qRSetId” Type=”Edm.Int32″/>

<ReturnType Type=”Edm.String”/>

</Action>

Let’s test the above URL for function using Postman to see the result:

[POST] – https://api.businesscentral.dynamics.com/v2.0/1e4fc386-962e-4a20-8364-d5aeb65e2485/Test/ODataV4/QRCodeGenerator_GetQRSetImageAsJSON?Company=CRONUS USA, Inc.

Authorization:  Basic Auth

Username: ASHWINI.TRIPATHI

Password: xjAtAtTaFhgXkgR4M5WoHapotvJNmqJ5//XBYK2v5s4= (Web Service Access Key)

JSON Parameter to Function: (Body raw:JSON)

{

    “qRSetId” : “6”

}

Result Body:

{

    “@odata.context”: “https://api.businesscentral.dynamics.com/v2.0/1e4fc386-962e-4a20-8364-d5aeb65e2485/Test/ODataV4/$metadata#Edm.String&#8221;,

    “value”: “iVBORw0KGgoAAAANSUhEUgAAApQAAAKUAQMAAACAATp/AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAGUExURQAAAP///6XZn90AAAAJcEhZcwAADsMAAA7DAcdvqGQAAAHtSURBVHja7dpbasMwEAXQ2YH3v0vvwKVBsZ44DZ4UWs58BEnMHH1eYjuO9NqZTCaTyWQymUwmk8lkMplMJpPJZDKZ/8KMsbb27Ls3St+2bmYymUwmM8Ws58N2b+FiXjQzmUwmk3nTLMN1qkPq6LqZyWQymczPmUdTwxVMJpPJZP6G+di0/7lqH5PJZDKZnzOnK7ZzW2tbNzOZTCaTmWIOtbXw9DM3M5lMJpOZYK6rPvSL9huJywkmk8lkMu+Yz0d9tR7HQ7INl9UWJpPJZDITzDIwv39arVbNTCaTyWRmmS0XbZ5Nq64uM47JZDKZzDfMdmrv4W47ZByTyWQymalm7S2rre0tq+eNxRw4JpPJZDITzDhjq8uu9p5udSLBZDKZTGae+UyxKd4GqWbc3MxkMplMZpZ5EXSdVPuYTCaTyUw12/kh1Dq4rVcZx2QymUzmG+aqinmcU12etdceTCaTyWSmmDHWkHaDNJ8xmUwmk5li1vM6GjFfu60nmEwmk8nMMuvUFGV7zPWjjGMymUwm87ZZt/Pqcc/wXJDJZDKZzE+apSXOV1TRf9HHZDKZTGaiub4i+ijb+48iDiaTyWQyM82h2rZYRFmsYpDJZDKZzHtmVjGZTCaTyWQymUwmk8lkMplMJpPJZDL/rHnsXwW1n/zFqtyZAAAAAElFTkSuQmCC”

}

Copy the Value and use any base64 – image converter tool, search on Google

You will get your QR Image:

Don’t try any URL or Passwords in this post as same is modified, and in images covered to hide actual url & passwords.

Hope you enjoyed learning from this post.

That’s all for this post, but visit again to learn from upcoming posts in this series, will post soon.

See you again in next post, till then keep exploring, learning and sharing with others.

Advertisement
AL, BC14, BC15, BC16, BC17, Business Central, Codeunit, Development Tips, Enum, Extension, How To, Install, JSON, SOAP, Tip & Tricks, V1, V2, Visual Studio Code, Wave 1, Wave 2, Web Client, Web Services, XML

Update Tracking Line, Post Shipment using Web Services in Business Central

Hi, today I will discuss Web Service with below requirement. You can check other earlier post on this topic using search on right side of this blog page.

I got one request on topic from one of my customer cum blog follower, case study is as follows:

a) Will update Qty to Ship on document using Web Service from other application

b) Update Tracking Line for the Shipment using Web Service from other application

c) Post the Shipment using Web Service from other application

To get this we will create an Extension using VS Code which will have:

a) Codeunit with some functions which will be called using Web Service

b) A XML file to automatically expose above codeunit upon publishing this extension

Let us start how to achieve above requirement:

I have created this in BC16, will be same for other versions too.

Creating a AL Project:

Update your app.json & launch.json as per your environment, authentication, dependencies, port etc.

Creating a Codeunit: (TrackingCodeWS.al)

This function will be used to update “Qty. to Ship” on Sales Line

InitLot function as name suggests.

GetNextEntryNo function as name suggests.

It will depend on how you design your codeunit, you may require or not depends on logic how you use them.

AssignLotSalesLine is function which fills the lot details to temp Reservation Entry Table.

CreateReservationEntrySalesLine is the main function which actually makes your Tracking Lines and assign to Sales Line as per information filled in TempReservationEntry table in above function.

PostSalesOrder function is used for posting your Shipment.

Creating XML file to Publish Web Service

This XML file will ensure publishing of Web Service on Install of the Extension. You can directly make entry to Web Service table but benefit of using XML is when to Uninstall your extension the Web Service too will be removed, else if entry made to table you will have to take care to same yourself.

After Install of Extension, your Web Service is automatically Published.

Consume Web Service from Visual Studio

Below is the C# code to consume Web Service created above, you can modify code as per your requirement.

In above code we added Service Reference to Web Service and called functions created in Codeunit.

You can see earlier posts for step wise instruction how to add Web Reference to the Web Service in Visual Studio.

UpdateQtyToShipSalesLine:

Here “1” is used for Document Type = Order,”1008″ is my order no, 10000 is the Line No., 2 is the Quantity to Ship.

AssignLotSalesLine:

“L0001” & “L0002” is my Lot No, Serial No. is blank in this case, 1 is the Quantity, last three parameter is same as in above function call.

PostSalesOrder:

First 2 Parameter is same as above function call Document Type & Order No, third parameter is Ship = TRUE, Fourth Parameter is Invoice = FALSE.

Conclusion

This post gives you overall Idea how you can use Web Service to handle Sales Document from Web Service, you can make required modification to achieve exactly as per your requirement.

AtomPub, Business Central, EDMX, How To, Information, JSON, OData, REST, RPC, Smtp, SOAP, Tip & Tricks, Web Client, Web Services, WSDL, XML

Web Services – Business Central Part- 2

Today in this post we will continue from where we left our previous post, if you missed or wish to have a look you can find her in this link.

Web Services – Business Central Part- 1

We saw in our previous post, you expose an OData service that can be accessed from a URL by using a web browser or any other HTTP client.

You need the URL of the OData page or query web service

https://server:webserviceport/serverinstance/oData/web service”

If you use the attribute ?$format=atom you will get an AtomPub document

https://KSD-DESKTOP:7748/BC130/OData/Customers?$format=atom

If you use the attribute ?$format=json you will get an JSON document

https://KSD-DESKTOP:7748/BC130/OData/Customers?$format=json

You can obtain service metadata documents for either page or query web services.

https://ksd-desktop:7748/BC130/OData/$metadata

SOAP Web Services

If your client requests another transport protocol than HTTP or HTTPS, then you can use SOAP as it also supports, for example, SMTP.

Microsoft is heavily investing in REST and OData, and certainly with the online apps like Power BI, PowerApps, and others.  So at this point SOAP isn’t the primary choice for web services anymore.

We can find the available SOAP web services at the same page where we define the OData web services.

If we go to the search box and then search for web services, This page is used to enable access to OData and SOAP web services.

ws-001

We could enable OData web services only with the object types of query and pages, and for SOAP web services, we can only enable it for pages and codeunits and not for queries.

For example soap url for my Customers Service will be as below:

https://KSD-DESKTOP:7747/BC130/WS/CRONUS%20International%20Ltd./Page/Customers

You can find some post related to consuming web service and working with web service for older versions but it can be used with business central too.

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

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

When you are exposing your object for web service, ensure that you use GUIAllowed function to supress the UI. Encapsulate the code that could cause in error, not your entire code.

Also the exceptions must be handled in order to facilitate that your web service don’t end the execution unexpectedly.

You must check with the GuiAllowed function when you are using one of the following dialog functions:

Close, Confirm, Error, Open, StrMenu, Update

The Message function is the only dialog function that doesn’t cause an exception.

Other keywords that you shouldn’t use are:

Page.Run, Page.RunModal, Activate, Report.Run, Report.RunModal, Hyperlink, File.Upload, File.Download

Hope you got some insight on Web Services.

I will come up with more features in other posts, till then keep exploring and learning, and take care of yourself.

API, AtomPub, Business Central, Development Tips, Dynamics 365, EDMX, How To, Information, JSON, OData, REST, RPC, SOAP, Tip & Tricks, Web Services, WSDL, XML

Web Services – Business Central Part- 1

You can use web services in Microsoft Dynamics 365 Business Central to expose data to the outside world.

You can use web services to get data from Microsoft Dynamics 365 Business Central and use it in other applications.

Any application, programing language or program that can work with XML and/or JSON for example: – Power BI, Microsoft PowerApps, a custom .NET program, etc. can connect to Microsoft Dynamics 365 Business Central fetch the available data.

A web service can also be used to create new or update existing data in the application.

Both XML (Extensible Markup Language) and JSON (JavaScript Object Notation) are open-standard file formats that are readable by humans. They are used to send information between clients over web services.

In this post we will discuss some terminology and differences between SOAP and OData. We will also learn on how to configure these services in Microsoft Dynamics 365 Business Central.

SOAP relies on HTTP(S), SMTP, FTP for message negotiation and transmission.

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. It uses SOAP envelope, which defines the message structure and how to process it.

A SOAP service exposes a WSDL (Web Services Description Language) file that describes how the service can be called, what parameters it expects and what data structure it returns. This file is an XML based document, and is targeted to be read by machines, not by humans.

OData (Open Data Protocol) is an open protocol that is designed to use and query RESTful APIs. An API (Application Programming Interface) is a set of routines and protocols that is used to communicate between different software components.

OData is built upon REST services and can be used to query REST services. By providing extra query parameters to a URL, you can for example limit or filter the result set.

SOAP exposes a WSDL document, OData exposes an EDMX document, which contains metadata for all the published web services.

You can see all the available OData web services by going to the search box and search for web services.  This page is used to enable access to OData and SOAP web services.

ws-001

OData web services can only be used with object types pages and queries, not with codeunits.  There are two versions of OData you can use, version 3 and version 4.  Version 4 is an enhanced version, and important to know is that version 4 returns JSON where version 3 returns AtomPub documents which are XML documents.

From this window you can add new or manage existing Web Services.

It is simple 2 Step task Add new object give service name and enable Publish checkbox. You will get your OData and/or SOAP URL.

For example: – object type page can be used in OData and in SOAP web services.

Let us explore the Web-Service Urls. For test purpose, I have created a Service with the name Customers for Page Customer Card.

https://ksd-Desktop:7748/BC130/ODataV4/Company(‘CRONUS%20International%20Ltd.&#8217;)/Customers

When we open, for example, our Customers web service, we can have a look at the URL.

First we have our server name and the port it’s using.  “https://ksd-Desktop:7748”

Then we have our instance name, which in our case is BC130.

Then our OData version, so version 4.  “ODataV4”

And then our company name, “Cronus International Ltd”.

And then finally our web service name, which is, in our case, “Customers”.

Let’s try this url, when we execute this url in our browser we get json file listing customers similar to below:

WS-003.jpg

Here etag is the unique identifier of each records, it will be required when you update records, will discuss later.

If I remove my service name then:

https://ksd-desktop:7748/BC130/ODataV4/Company(‘CRONUS%20International%20Ltd.&#8217;)

{“@odata.context”:”https://ksd-desktop:7748/BC130/ODataV4/$metadata#Company/$entity&#8221;,”Name”:”CRONUS International Ltd.”,”Evaluation_Company”:false,”Display_Name”:”CRONUS International Ltd.”,”Id”:”ab76c7b4-3c72-4805-86f7-7d91a10612ce”,”Business_Profile_Id”:””}

If I remove my Company Name then:

https://ksd-desktop:7748/BC130/ODataV4/

WS-004.jpg

If I open the metadata url

https://ksd-desktop:7748/BC130/ODataV4/$metadata

You will get EDMX file which shows metadata about the information in the OData web service.

ws-002

You can see some properties with our data types.  For example, if we scroll down, if we go to Customers, we have our entity type Customers, we can see some properties which our data types and max lengths.  We can also see what properties are primary key.  So this is number and so on.  So all useful information when you’re creating applications that use these OData web services.

Filtering the OData

You can set filter expression to the url few examples as below:

We will use the filter option top for limiting the result to top 5 records of customer.

After our service name, we type question mark, then the dollar sign, and then the word top equals 5.

For example :

https://ksd-desktop:7748/BC130/ODataV4/Company(‘CRONUS%20International%20Ltd.&#8217;)/Customers?$top=5

Now the query will result in only first 5 records for customer.

If we want to see next 5 records then we can append &$skip=5 on above url

https://ksd-desktop:7748/BC130/ODataV4/Company(‘CRONUS%20International%20Ltd.&#8217;)/Customers?$top=5&$skip=5

If you want to see specific customer you can modify url as:

https://ksd-desktop:7748/BC130/ODataV4/Company(‘CRONUS%20International%20Ltd.&#8217;)/Customers(‘10000’)

Please refer to EDMX file to find correct name of the fields if wants to filter on specific fields.

https://ksd-desktop:7748/BC130/ODataV4/Company(‘CRONUS%20International%20Ltd.&#8217;)/Customers(‘10000’)?$select=Name

You will get the result as below for above url query

“@odata.context”:”https://ksd-desktop:7748/BC130/ODataV4/$metadata#Company(‘CRONUS%20International%20Ltd.&#8217;)/Customers/$entity”,”@odata.etag”:”W/\”JzQ0O044eFNmcWdXV0NpYlhTZDhUdTlrdytZUmdQbWRkL2U4TzZ4UEsxNGtod0

E9MTswMDsn\””,”Name”:”The Cannon Group PLC”}

You can add other fields too by appending the url with ‘,’

Customers(‘10000’)?$select=Name,City,Address……………

As told earlier please refer to EDMX file for correct Fields Name or Property it is case sensitive.

You can remove the Primary Key from the url to get list of selected fields for all customers.

Customers?$select=Name,City,Address……………

https://ksd-desktop:7748/BC130/ODataV4/Company(‘CRONUS%20International%20Ltd.&#8217;)/Customers?$orderby=City&$select=Name,City,Address

You can use orderby to sort the data from other than Primary key, by default it is sorted by Primary Key.

You can use desc for descending sort.

https://ksd-desktop:7748/BC130/ODataV4/Company(‘CRONUS%20International%20Ltd.&#8217;)/Customers?$orderby=City desc&$select=Name,City,Address

You can use filter to filter specific field values as:

https://ksd-desktop:7748/BC130/ODataV4/Company(‘CRONUS%20International%20Ltd.&#8217;)/Customers?$filter=City eq ‘Zutphen’ or City eq ‘Atlanta’&$select=Name,City,Address

you will get output as:

WS-005.jpg

You can use expressions like [filter=Balance_LCY gt 0] or [filter=Location_Filter eq ‘BLUE’] etc.

I stop here for today. We have seen how the Web Services OData can be used to query records.

We will discuss about other stuffs in our next post in more details.

Till then keep exploring and learning, see you in next post. Take Care of yourself.

 

Application, Area, Development Tips, Extension Package, How To, Information, Library, Machine, Multitenancy, NAV 2017, Notification, Permission, PowerShell, Readiness Library, Series, Tagging, Time, Tip & Tricks, Web Services, What's New

New Changes or features for Developer and IT Pro Changes in Microsoft Dynamics NAV 2017

Although it is too early to discuss on features and capabilities which we are going to get in our new release, we should wait for exact information post release of same.

Here are few extracts from available documents pre-release of the product.

You will find most of the features similar to which we have discussed in our earlier posts for Madeira Preview Project.

New thing is capability of extensions and Web Services are enhanced and programmatically handling Notifications.

 

Extensions

Dynamics NAV 2017 includes many new capabilities for Extensions:

  1. You can now include reports, XMLports, and queries in your extension along with new custom report templates.
  2. Default or initial data for new tables as part of your extension. These data will be included in the package file (.navx) and inserted into the table at the time of installation of the extension.
  3. You can include translated captions and constants for one or more languages by including object language files in the extension package.
  4. A translation only extension could be built that translates strings for base objects or objects for another extension.
  5. You can include and deploy .NET interop types executed on the server, client-side JavaScript or WinForms extensibility control add-ins.
  6. Extension can include a web service and configure it for the tenant the extension is being installed for in a multitenant deployment.
  7. Two new C/AL functions NAVAPP.RESTOREARCHIVEDATA and NAVAPP.DELETEARCHIVEDATA, you can easily restore or delete archived table data during a reinstall or upgrade of the extension.
  8. Use the NAVAPP.RESTOREARCHIVEDATA function to simply copy the data back from the archive table when special upgrade logic is not required.
  9. Use the NAVAPP.DELETEARCHIVEDATA function in situations where you do not want to restore the archived data for the table.
  10. You can publish an extension to a Dynamics NAV Server instance that is configured with an Azure SQL Database using new parameters added to the Publish-NAVApp cmdlet. The new parameters are used to provide the location and credentials for connecting to an existing Azure SQL database you created.
  11. Users with the appropriate permissions in the application can install and uninstall extensions from the Extensions Management page. The page will display all of the extensions that are currently published.

 

Web Services in multitenant deployments

You can publish per-tenant web services in situations where a web service has not been published for all tenants of the service.

You can also package and deploy published web services for base objects or extension objects in an extension.

The packaged web services will be published to the tenant for which the extension is being installed.

 

Notifications in the UI

Dynamics NAV 2017 introduces a programmatic way to send non-intrusive notifications to the UI in the Dynamics NAV Web client.

Notifications provide users with information about a current situation, but do not require any immediate action or block users from continuing with their current task.

In the UI, notifications appear in the Notification bar (similar to validation errors) at the top of the page on which a user is currently working.

Notifications that are defined on sub-pages, for example in parts and FactBoxes, appear in the same Notification bar.

Validation errors on the page will be shown first.

In the development environment, you create notifications in C/AL by using the newNotification and NotificationScope data types and the following functions.

  1. MESSAGE specifies the content of the notification that appears in the UI
  2. SCOPE specifies the scope in which the notification appears, which can be LocalScope or GlobalScope.
  3. A LocalScope notification appears in context of what the user is currently doing, while GlobalScope notifications are not directly related to the current task. Note: GlobalScope is currently not supported.
  4. SEND sends the notification to be displayed by the client.
  5. ADDACTION adds an action on the notification. Actions enable you to create interactive notifications that provide users with different actions that they can take to address the notification, like opening an associated page for modifying data. A notification action calls a function in a codeunit that you define, passing the notification object in the call. You then add business logic to the function for handling the action.
  6. SETDATA and GETDATA set and retrieve a data property value for the notification, which is typically needed when actions are invoked.

The following example illustrates the simplified code for local scope notification that has an action:

VAR

CreditBalanceNotification@1170000000 :Notification;

PROCEDURECreditBalanceCheck@1170000023(Customer@1170000000 : Record 18);

BEGIN

//Create the notification

CreditBalanceNotification.MESSAGE(‘Thecustomer”s current balance exceeds

their credit limit’);

CreditBalanceNotification.SCOPE :=NOTIFICATIONSCOPE::LocalScope;

//Add a data property for the customernumber

CreditBalanceNotification.SETDATA(‘CustNumber’,Customer.”No.”);

//Add an action that calls the ActionHandler codeunit, which you define  in the next step.

CreditBalanceNotification.ADDACTION(‘Gohandle this’,

CODEUNIT::NavExtensionInstallationMgmt, ‘OpenCustomer’);

//Send the notification to the client.

CreditBalanceNotification.SEND;

END;

In the “Action Handler” codeunit, you would add code to handle the action in a global function, called OpenCustomer, which has a Notification data type parameter. You could use the GETDATA function to get the value of the data sent with the notification:

PROCEDUREOpenCustomer@1170000024(theNotification@1170000000 :

Notification);

VAR

CustNo@1170000001 : Code[20];

BEGIN

// Do the code to handle the action.Optionally retrieve data carried by

the notification.

CustNo :=theNotification.GETDATA(‘CustNumber’);

// …

END;

 

Setup data in the US version

The US version of Dynamics NAV 2017 includes two RapidStart packages that will enable a fast implementation for a new company.

These data packages come with a new Windows PowerShell script to upload to server – and can be enabled for new companies.

Create a new company in the Companies page, and choose the Enable assisted setup field.

Then, use the Import-NAVConfigurationPackageFile cmdlet to import the RapidStart packages.

Then open the new company, the packages are applied, and you will be taken through an assisted setup experience.

 

Application area tagging

The Application Areas system offers developers, administrators, and users the ability to define differentiated user experiences according to application scope.

By selecting a set of application areas, users only see UI elements that are specific to the application features that they need to perform their tasks.

When companies want to create differentiated user experiences, the Application Areas system should be considered as an option not compulsory to adopt.

 

Time series library

One of the most popular topics for machine learning is forecasting based on historical data.

Many algorithms are there that can do this, but you do not have to know them, because MS have wrapped them for us.

Five of these algorithms, are wrapped in one Azure ML experiment, added logic that compares different results and returns the best one accompanied by an indicator of the prediction’s quality.

There is also a generic API on top of this that allows Dynamics NAV developers create their own functionality that helps customers find the business-critical information that may be hidden in their database.

You can perform time-series analysis in the familiar development environment.

The time series library is used by the Sales and Inventory Forecast extension.

 

Source:- https://mbs.microsoft.com/Files/partner/NAV/Readiness_Training/ReadinessTrainingNews/WhatsNewDynamicsNAV2017LimitedBeta.pdf

I will come up with more details in my upcoming posts.

 

 

Development Tips, Dynamics 365, How To, Information, Maderia, Office Integration, Power Bi Content Pack, PowerBI.com, Tip & Tricks, Troubleshooting Tips, Web Services

Working with Project “Madeira” Content Pack for Power BI

In today’s post we will see how to use Power BI Content Pack for Madeira.

The content pack is preconfigured to work with sales data and financial data from the demonstration company that you get when you sign up for the Project “Madeira” preview.

To see your Project “Madeira” data in Power BI, you must have the following:

  • Access to Project “Madeira”.
  • Access to Power BI.

Before we start with connecting we will collect few information that we will require while connecting the Power BI to fetch data from Madeira.

User Name

Web Service Acess Key

Note down both value, if you don’t have Web Service Access Key Generate one and set appropriate Expiration date or Set Never Expire as shown below.

PowerBi_Madeira-1

Next open the Web Service Page.

Make sure all selected Web Service is running as in below screen.

The data is extracted from your Project “Madeira” company using web services to read live data. In Project “Madeira”, the Web Services window lists the web services that have been set up for you, including the following that are consumed by the content pack in Power BI:

  • ItemSalesAndProfit
  • ItemSalesByCustomer
  • powerbifinance
  • SalesDashboard
  • SalesOpportunities
  • SalesOrdersBySalesPerson
  • TopCustomerOverview

Note: If you change the name of any of these web services, the data will not show up in Power BI.

Note your URL of OData. Edit it to follow the format one shown in below screen.

PowerBi_Madeira-2

Now we have all our required information.

Open Power BI site and Get Data from Services as shown in below screen.

PowerBi_Madeira-3

Select Project “Madeira” Content Pack and click on Get.

PowerBi_Madeira-4

Enter the URL of Web Service we get in above step.

PowerBi_Madeira-5

Select Next.

Select Authentication method as Basic.

In User Name enter your user name as obtained in above step.

For Password ented the Web Service Access Key as obtained in above step.

PowerBi_Madeira-6

Choose Sign In.

After few minutes/seconds churning you will be ready with your first Dashboard from Madeira.

PowerBi_Madeira-7

Troubleshooting

“Parameter validation failed, please make sure all parameters are valid”
If you see this error after you enter your Project “Madeira” URL, make sure the following requirements are satisfied:

“Login failed”
If you get a “login failed” error when you log in to the dashboard, using your Project “Madeira” credentials, then this can be caused by one of the following issues:

  • The account you are using does not have permissions to read the Project “Madeira” data from your account.

    Verify your user account in Project “Madeira”, and make sure that you have used the right web service access key as the password, and then try again.

  • The Project “Madeira” instance that you are trying to connect to does not have a valid SSL certificate. In this case you’ll see a more detailed error message (“unable to establish trusted SSL relationship”).

    Note: Self-signed certificates are not supported.

“Oops”
If you see an “Oops” error dialog after you pass the authentication dialog, this is most frequently caused by a problem connecting to the data for the content pack.

Thats all for today’s post.

I will comeup with more details in my upcomming posts.

Til then keep exploring and learning.

 

Development Tips, How To, Information, Tip & Tricks, Web Services

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.

Development Tips, How To, Tip & Tricks, Web Services

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

 

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

 

Step 4: Create a DLL to use as Add-in to consume the Web Service itself in Navision.

We will start with Class Library Project in Visual Studio.

It’s very simple with few steps to follow, and we will be done with our requirement.

Enter Name and select the path for your project solution folder. In my case I am saving my project to the default location of Visual Studio. And I am naming my project as XMLData.

WebServiceUsage-8

Right click on the project folder and Add Service reference to the project.

WebServiceUsage-9

Enter your Web Service URL and click on GO.

Once your Service is listed, enter the Reference Namespace. And click on OK to add the Service Reference to the project.

WebServiceUsage-10

Click on app.config in Solution browser to open.

Verify your code similar to below.

WebServiceUsage-11

Build your Project to obtain the .dll file.

WebServiceUsage-12

Below screen shows we have no errors and the .dll file is created successfully.

WebServiceUsage-13

Locate the .dll file in your Project folder similar to path shown below. Copy your dll file.

WebServiceUsage-14

Create a folder and paste your .dll file to Service & RTC folder, as shown in below screen.

WebServiceUsage-15

 

We are ready with the Add-in, which we will use in our next post to consume our service with the help of this dll, and call the method to obtain our file for further processing.

That’s all for this post, I will be back with next post in series soon.

Till then keep practicing.

 

To be Continued….

 

Data, Development Tips, How To, Information, Tip & Tricks, Web Services, XMLports

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

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

 

Step 1: Create a XML Port to Export Data in XML Format using XMLPort and save at some specified Location.

Here we will be creating just for demo purpose simple XMLPort for Exporting Data from Navision Database in XML Format.

WebServiceUsage-2

We are using very simple structure for our XMLPort.

Make sure you set the properties accordingly as we are exporting the data in XML Format.

WebServiceUsage-3

Save the XMLPort at available id and suitable name.

 

Step 2: Create a Codeunit to call XML Port and retrieve data in XML Format in Text Variable.

Here we will create a Codeunit with few helpful functions which will call the XMLPort to Export the data and save in temp file.

Further retrieve the data from the file in XML Format.

Return the data retrieved above to the calling program/ function.

To start with let us start with creating some Global Variables.

WebServiceUsage-4

Next we will add one Function as below.

WebServiceUsage-5

Next we will add one more Function as below.

WebServiceUsage-6

Save the Codeunit at available Id and suitable Name.

 

Step 3: Expose/Publish the Codeunit as web service.

Open Web Services Page and add your Codeunit created above. Use your relevant ID on which you saved your Codeunit.

WebServiceUsage-7

 

Tick the Published to Expose the Codeunit as Web Service.

Rest in my Next post.

To Be Continued……

Data, Development Tips, How To, Information, Tip & Tricks, Web Services, XMLports

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

Introduction

Today in reply to one of my reader I am giving here steps how we can Export data using XMLPort and transfer data outside Navision using Web Services.

Lets discuss about the technology before I jump to the solution.

Few full forms which may help understanding while reading this post.

W3C – Web Services Architecture Working Group.

SOAP – Simple Object Access Protocol.

REST – Representational State Transfer.

WSDL – Web Service Description Language.

UDDI – Universal Description, Discovery & Integration.

AWS – Arbitrary Web Services.

XML – Extensible Markup Language.

HTTP – Hypertext Transfer Protocol.

 

What is Web Service?

W3C defines Web Service as : A software system designed to support interoperable Machine-to-Machine interaction over a network.

Web service can be defined as service offered by an electronic devices to another electronic devices, which communicate with each other over www.

W3C defines web services has an interface described in a machine-process able format WSDL.

Other systems I with the web service in a manner prescribed by its description using SOAP messages, typically conveyed using HTTP with an XML serialization in conjunction with other web-related standards.

Later W3C extended the definition:-

REST – compliant web services, in which the primary purpose of the service is to manipulate representations of web resources using a uniform set of stateless operations.

Arbitrary Web Services –  the services may expose an arbitrary set of operations.

WebServiceUsage-1-2

UDDI  defines which software system need to be contacted for which type of data.

Once the system is discovered to be contacted, the contact is established using SOAP.

Service provider system validate the request by referring the WSDL file, process the request and send the data using SOAP protocol.

 

Web Service is a method of communication that allows two software system to exchange the data over the internet.

  • Two systems may use different software which could be using different programming languages.
  • Almost all type of software interpret XML tags.
  • Web Services can be used to exchange data between two systems in form XML files.

WebServiceUsage-1-3

XML is used to tag the data.

SOAP is used to transfer the data.

WSDL is used to describe the services available.

UDDI lists what service are available.

Human to machine communication is utilized for machine-to-machine communication, used for transferring machine readable files such as XML & JSON formats.

Web services use SOAP over HTTP protocol, facilitating to use your existing low-cost internet for implementing Web Service.

Rules for communication between two different systems:

All the rules are defined in WSDL file.

  • How request to be send from one system to another.
  • What all parameters need to be send while requesting data.
  • What structure to be used for generating data (Normally data is exchanged in XML format) which is validated against .xsd file.
  • What errors to be generated in case of failure of rule communication set.

 

Web Services that uses Markup Language:

  • JSON-RPC
  • JSON-WSP
  • Web template
  • Web Service Description Language (WSDL)
  • XML Interface for Network Services (XINS)
  • Web Services Conversation Language (WSCL)
  • Web Services Flow Language (WSFL)
  • WS-Meta data Exchange
  • Representational State Transfer (REST)
  • Remote Procedure Call (RPC)
  • XML Remote Procedure Call (XML-RPC)

 

No more theories lets come to our point.

There are other ways too to achieve the same, but here I am specific to the requirement to which I am answering.

Requirement is the Data in XML format file will be transmitted using Web Service, We will be using Navision Exposed Web Service to Export data using XMLPort and then send the content by consuming another Web Service exposed in Dot Net which will retrieve the XML content and update in some other system.

Assumption is these two endpoints can be two separate databases in same domain or two different companies of same organization operating at two different location sharing information via Web Services.

For the demo purpose I will be using Navision to publish the service for exporting the data and retrieve the data using Web Service exposed in Dot Net.

Since I have not in depth knowledge of Dot Net codes, so I have asked my college to prepare the Web Service for me and I am simply using it to show how we can do it.

Here I will be getting this done through below 5 Steps.

WebServiceUsage-1

Next Post in this Series will contain:

Step 1: Create a XML Port to Export Data in XML Format using XMLPort and save at some specified Location.

Step 2: Create a Codeunit to call XML Port and retrieve data in XML Format in Text Variable.

Step 3: Expose/Publish the Codeunit as web service.

 

Next Post in this Series will contain:

Step 4: Create a DLL to use as Add-in to consume the Web Service itself in Navision.

 

And the Final Post in this Series will contain:

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.

 

Please follow my upcoming post for Walkthrough to get above 5 steps done.

To Be Continued……….