Development

Generics in .NET Interop for NAV 2013

by Vjekoslav Babic on May 17, 2012

image.NET Framework is full of programming conceptual gems, that are now at the fingertips of us poor C/AL folks. One of those is generics. However, the C/AL support for generics at the first glance seems rather limited, and the help file says that you can’t specify data types, and that all generics will be instantiated with System.Object as their type.

However, with Microsoft Dynamics NAV 2013, there is a very simple way which allows you to use generics with other data types, as well. So, if .NET Framework Interoperability interests you a slightest bit, here’s a solution.

The example below will be for the System.Collections.Generic.Dictionary<,>, and I will show how to use instances of the Dictionary<,> object with any desired data type, without having to pull in any external assemblies.

[click to continue reading…]

{ 0 comments }

Passing strongly-typed data to Web services

by Vjekoslav Babic on February 22, 2012

imagePassing strongly-typed data to NAV Web services can be trickier than it seems. If you are lucky, you can make your method accept strongly-typed parameters, and you are good to go. However, if you just can’t avoid sending text data, your text must be encoded in EN-US format, otherwise it will cause problems (see this).

What the heck, just encode the data as EN-US, right? Not quite. There are a myriad of reasons why data can come in non-EN-US encoding, one of which is this: it’s the Web services, for Pete’s sake – anyone or anything can call them.

[click to continue reading…]

{ 4 comments }

Web Reference vs. Service Reference, Part 3

by Vjekoslav Babic on January 31, 2012

Al Pacino in "Devil's Advocate"Fasten your seatbelts, you are in for the next round of Web Reference vs. Service Reference, which brings an unexpected twist to the story. After giving reasons why not to use Web References, I’ll now put my devil’s advocate’s hat on, and try to have you change your mind.

It’s simple: there are situations where Service Reference won’t work as expected, and Web Service will.

[click to continue reading…]

{ 1 comment }

Web Reference vs. Service Reference, Part 2

by Vjekoslav Babic on January 30, 2012

imageA beauty of Web services is that they don’t need to care at all about who’s consuming them. Whether there is .NET on Windows, Java on Linux or some proprietary stuff on an iPad on the other end, they do exactly the same stuff.

To make it short: if something works on one platform and fails on another platform, it’s not the fault of the Web service being called, it’s the fault of the caller platform.

As I said in the last post, there are two ways, or platforms if you wish, native to .NET Framework, which you can use to connect to any Web services. And they don’t work exactly the same.

[click to continue reading…]

{ 2 comments }

Web Reference vs. Service Reference, Part 1

by Vjekoslav Babic on January 27, 2012

Smorgasbord! by Charles RoffeyOnce upon a time, Freddy has delivered a great series on connecting to NAV Web Services from a smorgasbord of technology flavors. If you are a .NET enthusiast, like me, the obvious choice is to connect through the tools that are at your disposal in Visual Studio: the proxy classes.

A proxy class is a class which wraps a Web service functionality into a strongly-typed .NET object, and allows simpler communication through Web services. It hides away all intricacies of SOAP communication, authentication, serialization and deserialization, and exposes simple, easy-to-use objects. Every NAV Web service results in a series of proxy classes, and in Visual Studio the generation of those classes is as simple as clicking a mouse a couple of times.

[click to continue reading…]

{ 0 comments }

Bug theater in Web services #5

January 23, 2012

Last Monday I’ve attended my second daughter’s birth, and then spent the week trying to relieve my wife as much as possible from anything but breastfeeding. As a matter of fact, I’d like to keep doing it, it was not only a great break from daily worries, but also a fantastic occasion to spend all [...]

[click to continue reading…]

Bug theater in Web services #4

January 16, 2012

In my country, there’s a saying: “A good horse has a hundred flaws; a bad one has only one.” It’s bad. People have asked me why I am doing this, and if I hate Web services because I’m blogging about their flaws. In fact, I love Web services, and as I said in the first [...]

[click to continue reading…]

Bug theater in Web services #3

January 13, 2012

Soren has taught me yesterday that some of the bugs I encountered have been properly disinsected by Microsoft, so other than the workarounds I suggested, there is an option to apply the hotfix and forget about that one. Today, I’ll explain a not so critical bug, as the one yesterday, but depending on what exactly [...]

[click to continue reading…]

Bug theater in Web services #2

January 12, 2012

The bug with which I started this series is nothing critical. It manifests rarely, you can easily work around it. It’s in the “so what” category. But the one I’ll talk about today is a tough beast, with not-so-easy workarounds that cause as much headache as the bug itself. So, here comes bug #2: setting [...]

[click to continue reading…]

Bug theater in Web services #1

January 11, 2012

If something, Stratus has taught me how buggy the implementation of Web services in Microsoft Dynamics NAV is. Let me be clear from the onset: Web services are a great functionality in NAV, one of the best additions (together with .NET interop) to NAV stack in a long while. But it’s buggy. Being buggy doesn’t [...]

[click to continue reading…]