<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Navigate Into Success</title>
	
	<link>http://navigateintosuccess.com</link>
	<description>Ensuring Microsoft Dynamics NAV implementation success since 2003</description>
	<lastBuildDate>Tue, 22 May 2012 08:52:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/NavigateIntoSuccess" /><feedburner:info uri="navigateintosuccess" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>NavigateIntoSuccess</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>NAV 2013 beta mini-launch at Adriatics Community</title>
		<link>http://feedproxy.google.com/~r/NavigateIntoSuccess/~3/QtA3xjFZKRM/nav-2013-beta-mini-launch-at-adriatics-community</link>
		<comments>http://navigateintosuccess.com/blog/nav-2013-beta-mini-launch-at-adriatics-community#comments</comments>
		<pubDate>Tue, 22 May 2012 08:52:04 +0000</pubDate>
		<dc:creator>Vjekoslav Babic</dc:creator>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[NAV 2013]]></category>
		<category><![CDATA[Adriatics]]></category>
		<category><![CDATA[Application]]></category>
		<category><![CDATA[Ivan Koletić]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://navigateintosuccess.com/?p=1180</guid>
		<description><![CDATA[If you want to learn more about the upcoming release of Microsoft Dynamics NAV 2013, and you are from Zagreb, or don’t mind coming to it, the next community event of Microsoft Dynamics Community Adriatics will be fully dedicated to NAV 2013. There are going to be two presentations. In the first one on the [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><a title="Microsoft Community Croatia" href="http://www.mscommunity.hr/"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 0px 0px 8px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top: 0px; border-right: 0px; padding-top: 0px" title="Microsoft Comomunity Croatia" border="0" alt="Microsoft Comomunity Croatia" align="right" src="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/05/image3.png" width="202" height="143" /></a>If you want to learn more about the upcoming release of Microsoft Dynamics NAV 2013, and you are from Zagreb, or don’t mind coming to it, the next community event of Microsoft Dynamics Community Adriatics will be fully dedicated to NAV 2013.</p>
<p>There are going to be two presentations. In the first one on the topic of “What’s new in application functionality”, hosted by Ivan Koletić, a member of Microsoft Dynamics NAV product team, who will give an overview of new application features in NAV 2013, and by now you should already know there are plenty.</p>
<p>The second presentation will be about “What’s new in technology”, and will be hosted by me. I won’t be doing any deep-dive this time, and I’ll provide a cloud-perspective overview of a myriad of architecture changes and technology improvements in NAV 2013.</p>
<p>Both of these presentations are merely going to be an introduction in the series of the presentations that will follow over the next several community events. It’s going to be an exciting summer and fall.</p>
<p>If you would like to attend, then please register your attendance (for free, of course) at the <a title="11. sastanak Microsoft Dynamics Community Adriatics" href="http://www.mscommunity.hr/Event/Detail/359" target="_blank">event homepage</a>. We are looking forward to seeing you there!</p>
<hr />
Read this post at its original location at <a href="http://navigateintosuccess.com/blog/nav-2013-beta-mini-launch-at-adriatics-community">http://navigateintosuccess.com/blog/nav-2013-beta-mini-launch-at-adriatics-community</a>, or visit the original blog at <a href="http://navigateintosuccess.com/" title="Navigate Into Success">http://NavigateIntoSuccess.com</a>. 47fc2f5642456dfd71e5581a3785c625<img src="http://feeds.feedburner.com/~r/NavigateIntoSuccess/~4/QtA3xjFZKRM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://navigateintosuccess.com/blog/nav-2013-beta-mini-launch-at-adriatics-community/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://navigateintosuccess.com/blog/nav-2013-beta-mini-launch-at-adriatics-community</feedburner:origLink></item>
		<item>
		<title>Generics in .NET Interop for NAV 2013</title>
		<link>http://feedproxy.google.com/~r/NavigateIntoSuccess/~3/J_FAGEEPpww/generics-in-net-interop-for-nav-2013</link>
		<comments>http://navigateintosuccess.com/blog/generics-in-net-interop-for-nav-2013#comments</comments>
		<pubDate>Thu, 17 May 2012 22:55:54 +0000</pubDate>
		<dc:creator>Vjekoslav Babic</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[NAV 2013]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[C/AL]]></category>
		<category><![CDATA[Dictionary]]></category>
		<category><![CDATA[DotNet]]></category>
		<category><![CDATA[Generics]]></category>
		<category><![CDATA[Interop]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://navigateintosuccess.com/?p=1175</guid>
		<description><![CDATA[.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 [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><a href="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/05/image2.png"><img style="background-image: none; border-right-width: 0px; margin: 0px 0px 0px 8px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" align="right" src="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/05/image_thumb.png" width="202" height="143" /></a>.NET Framework is full of programming conceptual gems, that are now at the fingertips of us poor C/AL folks. One of those is <a title="An Introduction to C# Generics" href="http://msdn.microsoft.com/en-us/library/ms379564(v=vs.80).aspx" target="_blank">generics</a>. 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.</p>
<p>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.</p>
<p>The example below will be for the System.Collections.Generic.Dictionary&lt;,&gt;, and I will show how to use instances of the Dictionary&lt;,&gt; object with any desired data type, without having to pull in any external assemblies.</p>
<p><span id="more-1175"></span>
<p><strong>The Solution</strong></p>
<p>Before I show the example, I’ll first explain the solution.</p>
<p>Declaratively, you can’t declare a generic variable, and specify the type. C/SIDE is just not (yet) that flexible. But that doesn’t matter, because .NET Framework includes a nice feature which allows you to create instances of any type on the fly: <a title="Reflection in the .NET Framework" href="http://msdn.microsoft.com/en-us/library/f7ykdhsy(v=vs.100).aspx" target="_blank">Reflection</a>.</p>
<p>By using reflection, you can create an instance of a generic type, and specify which type(s) it should use, all with very little coding. In the examples that follow, I’ll create an instance of Dictionary&lt;string,int&gt;.</p>
<p>The whole process in C# would look, more or less, like this:</p>
<div>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet">

Dictionary&lt;<span style="color: #0000ff">string</span>, <span style="color: #0000ff">int</span>&gt; dict =

    Activator.CreateInstance(

        <span style="color: #0000ff">typeof</span>(Dictionary&lt;,&gt;).MakeGenericType(

            <span style="color: #0000ff">new</span> Type[]

                {

                    <span style="color: #0000ff">typeof</span> (<span style="color: #0000ff">string</span>), 

                    <span style="color: #0000ff">typeof</span> (<span style="color: #0000ff">int</span>)

                })) <span style="color: #0000ff">as</span> Dictionary&lt;<span style="color: #0000ff">string</span>, <span style="color: #0000ff">int</span>&gt;;
</pre>
</div>
<div>&#160;</div>
<div>Okay, it’s kind of hax0rish, because all is inline, so if you prefer it step by step, here it goes:</div>
<div>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet">

<span style="color: #008000">// Step 1</span>

<span style="color: #008000"></span>Type[] types =

    <span style="color: #0000ff">new</span> Type[]

        {

            <span style="color: #0000ff">typeof</span> (<span style="color: #0000ff">string</span>),

            <span style="color: #0000ff">typeof</span> (<span style="color: #0000ff">int</span>)

        };

<span style="color: #008000"></span>&#160;

<span style="color: #008000">// Step 2</span>

<span style="color: #008000"></span>Type dictionaryType = <span style="color: #0000ff">typeof</span> (Dictionary&lt;,&gt;).MakeGenericType(types);

&#160;

<span style="color: #008000">// Step 3</span>

<span style="color: #008000"></span>Dictionary&lt;<span style="color: #0000ff">string</span>, <span style="color: #0000ff">int</span>&gt; dict = 

    Activator.CreateInstance(dictionaryType) <span style="color: #0000ff">as</span>

<span style="color: #0000ff">        </span>Dictionary&lt;<span style="color: #0000ff">string</span>, <span style="color: #0000ff">int</span>&gt;;
</pre>
</div>
<div>&#160;</div>
<p>Step 1 creates an instance of a 2-element array of Type. This is needed for creating a generic type using reflection.</p>
<p>Step 2 uses reflection to create a generic type of specified types. The types are specified in the array we created in the step 1.</p>
<p>Step 3 uses reflection to create an instance of the type created in step 2.</p>
<p>Now that we’ve seen it in C#, let’s map the same to C/AL.<br />
  </p>
<div>&#160;</div>
<p><strong>1. Declaration</strong></p>
<p>Let’s get it straight, you can’t declare a DotNet variable of a generic type, and specify the actual type (or types) it generalizes. The C/SIDE simply doesn’t allow that. But, don’t worry. Go ahead, and declare the following variables:</p>
<table border="1" cellspacing="0" cellpadding="2" width="492">
<tbody>
<tr>
<td valign="top" width="64">Name</td>
<td valign="top" width="426">Subtype</td>
</tr>
<tr>
<td valign="top" width="64">Dict</td>
<td valign="top" width="426">System.Collections.Generic.Dictionary`2.&#8217;mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&#8242;</td>
</tr>
<tr>
<td valign="top" width="64">Type</td>
<td valign="top" width="426">System.Type.&#8217;mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&#8242;</td>
</tr>
<tr>
<td valign="top" width="64">Activator</td>
<td valign="top" width="426">System.Activator.&#8217;mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&#8242;</td>
</tr>
<tr>
<td valign="top" width="64">Arr</td>
<td valign="top" width="426">System.Array.&#8217;mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&#8242;</td>
</tr>
<tr>
<td valign="top" width="64">String</td>
<td valign="top" width="426">System.String.&#8217;mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&#8242;</td>
</tr>
<tr>
<td valign="top" width="64">Int</td>
<td valign="top" width="426">&nbsp;</td>
</tr>
</tbody>
</table>
<p>Of course, all of the above are DotNet, except for the last one, which is Integer.</p>
<p>&#160;</p>
<p><strong>2. Creating an instance of an array</strong></p>
<p>To declare an instance of an array of type Type, we can call the CreateInstance method of the Array class, by providing the type of System.Type. Then we populate the array with the types of System.String, and System.Int32:</p>
<div id="codeSnippetWrapper">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet">

Arr := Arr.CreateInstance(GETDOTNETTYPE(Type),2);

Arr.SetValue(GETDOTNETTYPE(String),0);

Arr.SetValue(GETDOTNETTYPE(Int),1);
</pre>
<p></div>
<p>This isn’t nearly as elegant as in C#, but accomplishes the goal quite as nicely. Take a note of the <em>GETDOTNETTYPE</em> function – a new gem in C/AL, the equivalent of the <em>typeof</em> keyword in C#.</p>
<p>&#160;</p>
<p><strong>3. Creating the dictionary type</strong></p>
<p>To create the type for the Dictionary&lt;string,int&gt; that we need, we have two steps. First is to get the type of Dictionary, and the second is to use that type to reflect out the actual Dictionary type that we need, based on types specified in the array:</p>
<div id="codeSnippetWrapper">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet">

Type := GETDOTNETTYPE(Dict);

Type := Type.MakeGenericType(Arr);
</pre>
<p></div>
<p>Again, it can’t be a single line in C/AL, because the syntax of C/AL does not treat the result of the GETDOTNETTYPE as an object.</p>
<p>&#160;</p>
<p><strong>4. Creating an actual instance</strong></p>
<p>Finally, we create an actual instance of the Dictionary&lt;string,int&gt; object, exactly as we would in C# (except we do it in C/AL):</p>
<div id="codeSnippetWrapper">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet">Dict := Activator.CreateInstance(Type);</pre>
<p></div>
<p>There. And now we are ready to use it.</p>
<p>&#160;</p>
<p><strong>5. Testing if it really is what we need</strong></p>
<p>Testing generics is easy – if you pass on to it the arguments of invalid type, they’d complain loudly. So, let’s try to pass some valid ones, and an invalid one:</p>
<div id="codeSnippetWrapper">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet">

Dict.Add(<span style="color: #006080">'first'</span>,1);

Dict.Add(<span style="color: #006080">'second'</span>,2);

Dict.Add(<span style="color: #006080">'third'</span>,<span style="color: #006080">'three'</span>);
</pre>
<p></div>
<p>Here, at the 3rd line, it fails with the following message, exactly as expected: <em>This message is for C/AL programmers: A call to System.Collections.Generic.Dictionary`2[System.String,System.Int32].Add failed with this message: The type of one or more arguments does not match the method&#8217;s parameter type.</em></p>
<p>So, obviously, we have an actual instance of the Dictionary&lt;string,int&gt; which receives exactly those elements, and behaves exactly as we would expect from a true .NET Framework generic class: if we try to pass a value of incorrect type, it’s not going to be happy.</p>
<p>&#160;</p>
<p><strong>6. And now for something completely different</strong></p>
<p>If you know anything about generics, at this moment you should be puzzled, as I was when I first tried this out. All of the C/AL voodoo above is the equivalent of this code in C#:</p>
<div id="codeSnippetWrapper">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet">

Dictionary&lt;<span style="color: #0000ff">object</span>, <span style="color: #0000ff">object</span>&gt; dict =

    Activator.CreateInstance(

        <span style="color: #0000ff">typeof</span> (Dictionary&lt;,&gt;).MakeGenericType(

            <span style="color: #0000ff">new</span> Type[]

                {

                    <span style="color: #0000ff">typeof</span> (<span style="color: #0000ff">string</span>),

                    <span style="color: #0000ff">typeof</span> (<span style="color: #0000ff">int</span>)

                })) <span style="color: #0000ff">as</span> Dictionary&lt;<span style="color: #0000ff">object</span>, <span style="color: #0000ff">object</span>&gt;;
</pre>
<p></div>
<p>No need to try running it, it fails. Actually, it doesn’t fail, it returns null. The problem is, being strongly typed, the .NET runtime can’t cast Dictionary&lt;string,int&gt; as Dictionary&lt;object,object&gt;, and the declared type of Dictionary&lt;object,object&gt; can’t hold a value of Dictionary&lt;string,int&gt;. It’s apples and oranges—even though both are instances of the same generic type, it’s not the same actual type, and they are not typecast compatible.</p>
<p>When you declare a DotNet of a generic type, in this case the Dictionary type, it’s declaratively Dictionary&lt;object,object&gt;, so how in the earth did we manage to stuff Dictionary&lt;string,int&gt; into it?</p>
<p>As a matter of fact, we never did that. I can’t say for sure, but I’ll give an educated guess here. DotNet is never actually the exact type we declare, but a wrapper class around just about anything. I assume it actually wraps around System.Object, and then uses reflection to access the members of the actual object it wraps.</p>
<p>But in the end, why do we care? It does what we need it to do.</p>
<hr />
Read this post at its original location at <a href="http://navigateintosuccess.com/blog/generics-in-net-interop-for-nav-2013">http://navigateintosuccess.com/blog/generics-in-net-interop-for-nav-2013</a>, or visit the original blog at <a href="http://navigateintosuccess.com/" title="Navigate Into Success">http://NavigateIntoSuccess.com</a>. 47fc2f5642456dfd71e5581a3785c625<img src="http://feeds.feedburner.com/~r/NavigateIntoSuccess/~4/J_FAGEEPpww" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://navigateintosuccess.com/blog/generics-in-net-interop-for-nav-2013/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://navigateintosuccess.com/blog/generics-in-net-interop-for-nav-2013</feedburner:origLink></item>
		<item>
		<title>Hello, unicode!</title>
		<link>http://feedproxy.google.com/~r/NavigateIntoSuccess/~3/0jknXploFAI/hello-unicode</link>
		<comments>http://navigateintosuccess.com/blog/hello-unicode#comments</comments>
		<pubDate>Thu, 17 May 2012 08:11:52 +0000</pubDate>
		<dc:creator>Vjekoslav Babic</dc:creator>
				<category><![CDATA[NAV 2013]]></category>
		<category><![CDATA[Unicode]]></category>

		<guid isPermaLink="false">http://navigateintosuccess.com/?p=1171</guid>
		<description><![CDATA[你好，世界！გამარჯობა, მსოფლიო! હેલો, વિશ્વ! مرحبا، العالم! שלום, עולם! नमस्ते, दुनिया! こんにちは世界 ಹಲೋ, ವಿಶ್ವದ! 안녕하세요, 세계! Γεια σου, κόσμε! Привет, мир! வணக்கம், உலக! హలో, ప్రపంచం! สวัสดีโลก! No, no, I didn’t go fully crazy yet, but I’m surely closing in. Maybe it’s not at all such a big deal as I see it, but the new Unicode [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><a title="Flags, by borkur.net" href="http://www.flickr.com/photos/borkurdotnet/691053039/" target="_blank"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" align="right" src="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/05/image1.png" width="202" height="130" /></a>你好，世界！გამარჯობა, მსოფლიო! હેલો, વિશ્વ! مرحبا، العالم! שלום, עולם! नमस्ते, दुनिया! こんにちは世界 ಹಲೋ, ವಿಶ್ವದ! 안녕하세요, 세계! Γεια σου, κόσμε! Привет, мир! வணக்கம், உலக! హలో, ప్రపంచం! สวัสดีโลก!</p>
<p>No, no, I didn’t go fully crazy yet, but I’m surely closing in. Maybe it’s not at all such a big deal as I see it, but the new <a title="Unicode (Wikipedia)" href="http://en.wikipedia.org/wiki/Unicode" target="_blank">Unicode</a> support in Microsoft Dynamics NAV 2013 is just blowing my socks off. After a quarter century of being tied to a single code page of choice, NAV has finally been freed of it’s single byte per character legacy.</p>
<p><span id="more-1171"></span>
<p>So, the scribble above is not just me showing off with my ability to use Google translate, it’s a playground for you to copy select pieces of it and paste it all over NAV text fields in your NAV 2013 installation. You have one, don’t you? If not, <a title="Microsoft Dynamics NAV 2013 Beta" href="https://mbs.microsoft.com/partnersource/support/selfsupport/productreleases/msdnav2013betadownload.htm" target="_blank">go grab your copy</a>!</p>
<p>This Unicode thingy, it was obvious this was coming. It was not exactly officially confirmed earlier, but with the good riddance of the Classic stack, and having the whole new stack built entirely upon .NET Framework and SQL Server (which had Unicode since ages), retaining ASCII would actually required far more work than simply adding the so much desired <em>n</em> in front of all those varchars in the database. In memory, <a title="The Beauty and The Beast: NAV and .NET" href="http://navigateintosuccess.com/blog/the-beauty-and-the-beast-nav-and-net" target="_blank">everything was Unicode already anyway</a> and if you have been in Antwerp at NAV TechDays last year, you may remember this <a title=".NET and NAV Interop: The Beauty meets The Beast" href="http://www.mibuso.com/dlinfo.asp?FileID=1388" target="_blank">presentation with the demo</a>.</p>
<p>With NAV 2013 beta out, the sheer number of news is frightening, and I hope I just get enough time to blog as much as I’d love to. But I’m sure my colleagues would kick-off as well, and there will be oceans of useful information about NAV 2013 pouring in. That I can promise.</p>
<hr />
Read this post at its original location at <a href="http://navigateintosuccess.com/blog/hello-unicode">http://navigateintosuccess.com/blog/hello-unicode</a>, or visit the original blog at <a href="http://navigateintosuccess.com/" title="Navigate Into Success">http://NavigateIntoSuccess.com</a>. 47fc2f5642456dfd71e5581a3785c625<img src="http://feeds.feedburner.com/~r/NavigateIntoSuccess/~4/0jknXploFAI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://navigateintosuccess.com/blog/hello-unicode/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://navigateintosuccess.com/blog/hello-unicode</feedburner:origLink></item>
		<item>
		<title>Microsoft Dynamics NAV 2013 Beta Available!</title>
		<link>http://feedproxy.google.com/~r/NavigateIntoSuccess/~3/6YMI3eOhavQ/microsoft-dynamics-nav-2013-beta-available</link>
		<comments>http://navigateintosuccess.com/blog/microsoft-dynamics-nav-2013-beta-available#comments</comments>
		<pubDate>Mon, 14 May 2012 20:20:48 +0000</pubDate>
		<dc:creator>Vjekoslav Babic</dc:creator>
				<category><![CDATA[Dynamics NAV]]></category>
		<category><![CDATA[NAV]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Beta]]></category>
		<category><![CDATA[NAV 2013]]></category>
		<category><![CDATA[Partnersource]]></category>

		<guid isPermaLink="false">http://navigateintosuccess.com/?p=1168</guid>
		<description><![CDATA[I don’t know about you, but I think today is a great day: Microsoft Dynamics NAV 2013 Beta has been published on PartnerSource, and if you have access, you can download it from here. I’ve been playing around with CTPs for more quite a while, and even though I can’t share any specifics, I can [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top: 0px; border-right: 0px; padding-top: 0px" title="Beta" border="0" alt="Beta" align="right" src="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/05/image.png" width="202" height="141" />I don’t know about you, but I think today is a great day: Microsoft Dynamics NAV 2013 Beta has been published on PartnerSource, and if you have access, you can download it from <a title="Microsoft Dynamics NAV 2013 Beta" href="https://mbs.microsoft.com/partnersource/support/selfsupport/productreleases/msdnav2013betadownload.htm" target="_blank">here</a>.</p>
<p>I’ve been playing around with CTPs for more quite a while, and even though I can’t share any specifics, I can assure you: this is definitely the best release ever, technically, architecturally, functionally and from business value perspective. Whatever angle you take – this release is massive.</p>
<p>I believe I don’t exaggerate if I say that 2013 brings more news in comparison with 2009 R2, than 2009 brought in comparison with 5.0 SP1.</p>
<p>If you want to check more about what exactly is new, I suggest you read the white paper and accompanying documentation at the <a title="NAV 2013 Launch Portal" href="https://mbs.microsoft.com/partnersource/newsevents/news/MSD_NAV2013Launch.htm" target="_blank">NAV 2013 launch portal</a>, and I hope the MVPs soon get the clearance to blog about specific features. There are just so many fantastically exciting to-dos for this blog, about NAV 2013, that I’ll probably eat my fingernails – heck, the whole fingers! – in anticipation to be able to start.</p>
<hr />
Read this post at its original location at <a href="http://navigateintosuccess.com/blog/microsoft-dynamics-nav-2013-beta-available">http://navigateintosuccess.com/blog/microsoft-dynamics-nav-2013-beta-available</a>, or visit the original blog at <a href="http://navigateintosuccess.com/" title="Navigate Into Success">http://NavigateIntoSuccess.com</a>. 47fc2f5642456dfd71e5581a3785c625<img src="http://feeds.feedburner.com/~r/NavigateIntoSuccess/~4/6YMI3eOhavQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://navigateintosuccess.com/blog/microsoft-dynamics-nav-2013-beta-available/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://navigateintosuccess.com/blog/microsoft-dynamics-nav-2013-beta-available</feedburner:origLink></item>
		<item>
		<title>Dynamics Top 100 Nominations for 2012</title>
		<link>http://feedproxy.google.com/~r/NavigateIntoSuccess/~3/gceZWb_mzK4/dynamics-top-100-nominations-for-2012</link>
		<comments>http://navigateintosuccess.com/blog/dynamics-top-100-nominations-for-2012#comments</comments>
		<pubDate>Sat, 03 Mar 2012 11:52:04 +0000</pubDate>
		<dc:creator>Vjekoslav Babic</dc:creator>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[DynamicsWorld]]></category>
		<category><![CDATA[Top 100]]></category>

		<guid isPermaLink="false">http://navigateintosuccess.com/?p=1165</guid>
		<description><![CDATA[It’s the fourth year of DynamicsWorld’s Microsoft Dynamics Most Influential People Top 100 list, and it’s the nomination time. Last year I’ve somehow found my way onto this list (and I certainly didn’t nominate myself), and it seems somebody has nominated me this year too (and again, it wasn’t me). Now, I don’t want to [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><a title="DynamicsWorld" href="http://www.dynamicsworld.co.uk/"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="DynamicsWorld" align="right" src="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/03/image.png" width="202" height="134" /></a>It’s the fourth year of DynamicsWorld’s Microsoft Dynamics Most Influential People Top 100 list, and it’s the nomination time. Last year I’ve somehow found my way onto this list (and I certainly didn’t nominate myself), and it seems somebody has nominated me this year too (and again, it wasn’t me).</p>
<p>Now, I don’t want to influence you to put me on this list in 2012 again, but if you think I deserve it, I’d appreciate if you took time and voted for me. You can do it by sending an e-mail to <a title="top100@dynamicsworld.co.uk" href="mailto:top100@dynamicsworld.co.uk?subject=I am nominating Vjekoslav Babic">top100@dynamicsworld.co.uk</a>, tweeting my name with #dwtop100 hash-tag, commenting on <a title="Facebook" href="http://www.facebook.com/dynamicsworld.co.uk">Facebook</a>, or posting on <a title="LinkedIn" href="http://www.linkedin.com/groups?mostPopular=&amp;gid=2057697">LinkedIn</a>. Or you can do all of the above <img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/03/wlEmoticon-smile.png" /></p>
<p>Even though there is a lot of criticism of this list, it is still an indicator of person’s standing in the Dynamics community. I’ve heard people say “I don’t have a clue who this or that&quot; is” on the list, but that’s hardly a valid argument. The list doesn’t differentiate between CRM or ERP, let alone between different flavors of ERP, so of course not everybody will know everybody, and I also don’t have a clue who half of the list is, but still I bet they deserved to get there.</p>
<p>So, show me your support for my blog and my work in the Dynamics community by voting for me! Thanks in advance!</p>
<hr />
Read this post at its original location at <a href="http://navigateintosuccess.com/blog/dynamics-top-100-nominations-for-2012">http://navigateintosuccess.com/blog/dynamics-top-100-nominations-for-2012</a>, or visit the original blog at <a href="http://navigateintosuccess.com/" title="Navigate Into Success">http://NavigateIntoSuccess.com</a>. 47fc2f5642456dfd71e5581a3785c625<img src="http://feeds.feedburner.com/~r/NavigateIntoSuccess/~4/gceZWb_mzK4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://navigateintosuccess.com/blog/dynamics-top-100-nominations-for-2012/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://navigateintosuccess.com/blog/dynamics-top-100-nominations-for-2012</feedburner:origLink></item>
		<item>
		<title>Passing strongly-typed data to Web services</title>
		<link>http://feedproxy.google.com/~r/NavigateIntoSuccess/~3/Yx0jI8wAP3E/passing-strongly-typed-data-to-web-services</link>
		<comments>http://navigateintosuccess.com/blog/passing-strongly-typed-data-to-web-services#comments</comments>
		<pubDate>Wed, 22 Feb 2012 01:32:59 +0000</pubDate>
		<dc:creator>Vjekoslav Babic</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[BigText]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[C/AL]]></category>
		<category><![CDATA[Interop]]></category>
		<category><![CDATA[Strong typing]]></category>
		<category><![CDATA[Web services]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://navigateintosuccess.com/?p=1161</guid>
		<description><![CDATA[Passing 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). [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><a href="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/02/image1.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 0px 0px 8px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" align="right" src="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/02/image_thumb1.png" width="202" height="138" /></a>Passing <a title="Strong typing (Wikipedia)" href="http://en.wikipedia.org/wiki/Strong_typing" target="_blank">strongly-typed</a> 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 <a title="EN-US as Web Services default language" href="http://blogs.msdn.com/b/nav/archive/2011/10/03/en-us-as-web-services-default-language.aspx" target="_blank">this</a>).</p>
<p>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.</p>
<p><span id="more-1161"></span>
<p><strong>Are there real-life scenarios for this?</strong></p>
<p>Actually, there are. The most common one, which we have encountered in <a title="Stratus" href="/tags/stratus">Stratus</a> as well (but I’ve <a title="User Regional Settings vs NAV2009 Web Service problem (Mibuso)" href="http://www.mibuso.com/forum/viewtopic.php?f=32&amp;t=51197" target="_blank">seen it on Mibuso</a>, as well), is that you might need to pass an obscene amount of data between NAV and the consumer, and sometimes that data contains a variable number of parameters. Values for all the fields of any table, for example. Natural way of passing such data is through XML, and the only way to pass XML is through text.</p>
<p>And there we are – the only way in NAV to obtain decimals, or integers, or dates, or <em>strongly-typed data</em> in general, from text, is to call EVALUATE. And this naughty little function unfortunately isn’t as smart as being able to apply any format. It can only apply the format of the currently active language, and in Web services it defaults to EN-US.</p>
<p>To switch from theory to practice, if you receive the string ‘1.000’ in HR (or apparently ES) locales, it would get EVALUATEd to 1, whereas the value actually meant 1000 in HR or ES locales. If you pass the date ‘13-08-2012’ in NL locale, you would apparently get an invalid date error, and EVALUATE would fail.</p>
<p>Not really something you’d like to have in your database.</p>
<p><strong>How to pass the strongly typed data, then?</strong></p>
<p>The best way to pass large chunks of variable-structured data to NAV is by using XML, which is text, and is prone to problems with EVALUATE’s dependency on the actual locale.</p>
<p>So, how to get around it? By using .NET interop.</p>
<p>.NET comes with a great capability which is called <em>serialization</em>. Serialization allows any object in memory (okay – this <em>any </em>comes with a disclaimer) to be streamed into binary or XML representation, which can then be <em>deserialized</em>, i.e. to instantiate the same object with the same state, from that binary or XML representation. Of course, serialization can work with other formats, as well, but binary and XML are the most common.</p>
<p>Imagine this:</p>
<div id="codeSnippetWrapper"><a href="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/02/image2.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/02/image_thumb2.png" width="250" height="94" /></a>    </div>
<p>And you then use this class in a function:</p>
<div id="codeSnippetWrapper"><a href="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/02/image3.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/02/image_thumb3.png" width="354" height="99" /></a>    </div>
<p>Serialization can turn this into the following XML:</p>
<div id="codeSnippetWrapper"><a href="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/02/image4.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/02/image_thumb4.png" width="400" height="110" /></a>    </div>
<p>Beauty of this is that it can be deserialized back into an instance of class Person, without losing any information, and without having to worry about current regional settings.</p>
<p>Serialization is a much more complex topic than just what I’m going to show, but to make it serializable, the only thing you need to do with your class is this:</p>
<div id="codeSnippetWrapper"><a href="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/02/image5.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/02/image_thumb5.png" width="420" height="298" /></a>    </div>
<p>Then simply call Serialize to return the string, or Deserialize to return an instance from the string.</p>
<p>How that you have that class, deploy it as a .NET add-in into your NAV instance, and write a function such as this:</p>
<p><a href="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/02/image6.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/02/image_thumb6.png" width="300" height="219" /></a></p>
<p>Then simply test to make sure it really does exactly what it says on the tin:</p>
<p><a href="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/02/image7.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/02/image_thumb7.png" width="480" height="351" /></a></p>
<p>You can download the .NET project and the required FOB file by <a title="Strongly-Typed data passing demo" href="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/02/StronglyTypedDemo.zip" target="_blank">clicking here</a>.</p>
<p>I hope this was helpful. Please share your thoughts.</p>
<hr />
Read this post at its original location at <a href="http://navigateintosuccess.com/blog/passing-strongly-typed-data-to-web-services">http://navigateintosuccess.com/blog/passing-strongly-typed-data-to-web-services</a>, or visit the original blog at <a href="http://navigateintosuccess.com/" title="Navigate Into Success">http://NavigateIntoSuccess.com</a>. 47fc2f5642456dfd71e5581a3785c625<img src="http://feeds.feedburner.com/~r/NavigateIntoSuccess/~4/Yx0jI8wAP3E" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://navigateintosuccess.com/blog/passing-strongly-typed-data-to-web-services/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://navigateintosuccess.com/blog/passing-strongly-typed-data-to-web-services</feedburner:origLink></item>
		<item>
		<title>Microsoft Dynamics Mayhem</title>
		<link>http://feedproxy.google.com/~r/NavigateIntoSuccess/~3/RNIpka1sd2Y/microsoft-dynamics-mayhem</link>
		<comments>http://navigateintosuccess.com/blog/microsoft-dynamics-mayhem#comments</comments>
		<pubDate>Thu, 16 Feb 2012 09:13:59 +0000</pubDate>
		<dc:creator>Vjekoslav Babic</dc:creator>
				<category><![CDATA[Book]]></category>
		<category><![CDATA[Dynamics]]></category>
		<category><![CDATA[PACKT]]></category>

		<guid isPermaLink="false">http://navigateintosuccess.com/?p=1144</guid>
		<description><![CDATA[If you thought “here he comes again” with the bugs and stuff, no – this is not about it. This is just about a new sales campaign launched by PACKT Publishing, the good guys who published my and Dave’s book three years ago, and plenty other good books thereafter, as well. So, if you haven’t [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><a href="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/02/image.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top: 0px; border-right: 0px; padding-top: 0px" title="" border="0" alt="" align="right" src="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/02/image_thumb.png" width="193" height="144" /></a>If you thought “here he comes again” with the bugs and stuff, no – this is not about it. This is just about a new sales campaign launched by <a title="PACKT Publishing" href="http://www.packtpub.com/" target="_blank">PACKT Publishing</a>, the good guys who published my and Dave’s book three years ago, and plenty other good books thereafter, as well.</p>
<p>So, if you haven’t purchased my book yet, or any other cool Dynamics book, now is the time: during February, PACKT is giving 10% to 30% percent discount on all of its Dynamics books and offerings. Printed books are 20% off, e-books are 30% off, so this might be a good time to support us poor guys who have to make a living from literary efforts <img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/02/wlEmoticon-smile.png" /></p>
<p>Find more about the offer here <a title="http://www.packtpub.com/news/microsoft-dynamics-mayhem" href="http://www.packtpub.com/news/microsoft-dynamics-mayhem">http://www.packtpub.com/news/microsoft-dynamics-mayhem</a>.</p>
<hr />
Read this post at its original location at <a href="http://navigateintosuccess.com/blog/microsoft-dynamics-mayhem">http://navigateintosuccess.com/blog/microsoft-dynamics-mayhem</a>, or visit the original blog at <a href="http://navigateintosuccess.com/" title="Navigate Into Success">http://NavigateIntoSuccess.com</a>. 47fc2f5642456dfd71e5581a3785c625<img src="http://feeds.feedburner.com/~r/NavigateIntoSuccess/~4/RNIpka1sd2Y" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://navigateintosuccess.com/blog/microsoft-dynamics-mayhem/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://navigateintosuccess.com/blog/microsoft-dynamics-mayhem</feedburner:origLink></item>
		<item>
		<title>Web Reference vs. Service Reference, Part 3</title>
		<link>http://feedproxy.google.com/~r/NavigateIntoSuccess/~3/zjK-3eBqlN4/web-reference-vs-service-reference-part-3</link>
		<comments>http://navigateintosuccess.com/blog/web-reference-vs-service-reference-part-3#comments</comments>
		<pubDate>Tue, 31 Jan 2012 00:44:13 +0000</pubDate>
		<dc:creator>Vjekoslav Babic</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Deserialization]]></category>
		<category><![CDATA[Fiddler]]></category>
		<category><![CDATA[Regular Expression]]></category>
		<category><![CDATA[Serialization]]></category>
		<category><![CDATA[Service Reference]]></category>
		<category><![CDATA[SOAP]]></category>
		<category><![CDATA[Web Reference]]></category>
		<category><![CDATA[Web services]]></category>
		<category><![CDATA[WSDL]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://navigateintosuccess.com/?p=1137</guid>
		<description><![CDATA[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 [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 0px 0px 8px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top: 0px; border-right: 0px; padding-top: 0px" title="Al Pacino in &quot;Devil&#39;s Advocate&quot;" border="0" alt="Al Pacino in &quot;Devil&#39;s Advocate&quot;" align="right" src="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/01/image11.png" width="202" height="147" />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 <em>devil’s advocate</em>’s hat on, and try to have you change your mind.</p>
<p>It’s simple: there are situations where Service Reference won’t work as expected, and Web Service will.</p>
<p><span id="more-1137"></span>
<p>This time, you don’t need to create new objects, you can simply run what’s already there in NAV. Just publish the page 7002 Sales Prices as a Web service, then call ReadMultiple on that Web service both through a Web Reference and a Service Reference.</p>
<p>Okay – before you do that – you’ll want to delete (or change) the name of the Currency Code Filter control – it can’t have the same name as the Sales Type Filter Control – Web services won’t allow that (why does RTC not complain about this, beats me royally).</p>
<p>Also, if any of the calls returned no data, which is what a virgin Cronus database would do, feed some sales prices into it first, then call ReadMultiple.</p>
<p>Now observe the results. The Web Reference code actually returned all the data as expected. The Service Reference is funny: every row returned will simply have the Key property populated with correct data, all other fields will simply be either null (if nullable) or their default value (if not nullable). Unbelievable, isn’t it?</p>
<p>Looking at the XML passed on by NAV as a SOAP response, you can see that it actually contains all the data, just as expected. So what is it, then?</p>
<p>Figuring this one out is not as difficult as it might seem at first. Of course, the problem is not in NAV (actually, there is <em>a</em> problem in NAV, but not that NAV doesn’t return the correct info, it’s something else, that I’ll talk about later) – the problem is actually in how Web Reference and Service Reference deserialize the XML.</p>
<p>To understand how each of them do that, you need to check the source code of the generated proxy class. You can do it either by</p>
<p>a) right-clicking the proxy class name in any place in the code where it is used and choosing Go To Definition (or Go To Declaration, if you are using Resharper);</p>
<p><img style="border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/01/image_thumb10.png" /></p>
<p>b) by clicking the Show All Files in Solution Explorer</p>
<p><a href="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/01/image12.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/01/image_thumb11.png" /></a></p>
<p>then locating the reference source (always called Reference.cs):</p>
<p><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/01/image13.png" /></p>
<p>The Reference.cs file contains all the classes needed for handling the SalesPrice Web service, and inspecting the SalesPrice class itself, which is the class representing the NAV Sales Price record, inspecting the serialization attributes will reveal the culprit in a split second:</p>
<p><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/01/image15.png" width="408" height="372" /></p>
<p>Do you see what I see?</p>
<p>It’s the Order=x parameter of the XmlElementAttribute. An innocent looking thing, yet it causes such a disaster in deserialization of the data. What it does is that it basically instructs the XML deserializer to only continue deserializing the XML as long as the order of elements in the SOAP message is correct. If elements come out of order, deserialization doesn’t fail, but it simply ignores all the elements that come at, or after the position, of the first element which violated the order.</p>
<p>The Order parameter, as well as all of the serialization attributes, are present in the Service Reference proxy classes, but not present in Web Reference ones. That simply means that deserialization of the SOAP message will not take the order of the elements into account for Web References, whereas it will do so for the Service References.</p>
<p>Which in fact means there must be something wrong with the SOAP response. Why doesn’t it return the elements in the required order?</p>
<p>To figure that out, let’s inspect the message, and compare it to the WSDL definition of the Web service.</p>
<p>This is what WSDL defines:</p>
<p><a href="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/01/image16.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/01/image_thumb12.png" width="495" height="218" /></a></p>
<p>And this is what the SOAP response contains (I use <a title="Fiddler" href="http://fiddler2.com/fiddler2/" target="_blank">Fiddler</a> to catch stuff like this):</p>
<p><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/01/image17.png" width="494" height="331" /></p>
<p>And there you go. Since Key property did deserialize well, and since the proxy class said it needed it at position 0, s’il vous plait, then it must be whatever came at position 1 that made the deserialization give up.</p>
<p>See it? The SalesTypeFilter element, which is present in the SOAP response, is nowhere to be seen in the WSDL definition. All other elements come in order (please note that Order will only make the deserialization fail if elements are out of order, or extra elements are present – it won’t fail if an element is not present, but the elements that are present are in order).</p>
<p>Why this SalesTypeFilter found its way into SOAP, but was too shy to show up in WSDL, is a mystery to me, so I attribute it to a bug in Web services. And since it’s the Web services that returned that element, you can’t do much about it.</p>
<p>So, is this a dead-end, then? I mean, you must use Service Reference because it can fail at reading XML representation of unprintable characters, and you can’t use Service Reference because it can fail at ordering at deserialization.</p>
<p>Fortunately, it’s not that bad.</p>
<p>The workaround here is simple. You simply take out all Order parameters of every single XmlElementAttribute attribute (yes, you can edit the Reference.cs and modify the definition of a proxy class!), and all of a sudden the Service Reference deserializes the SOAP as happily as any Web Reference.</p>
<p>There are two problems with this solution: first, you absolutely must not update the Service Reference, because it would stick those Order parameters back where they were, and second, you must do this for every single class if you want to be sure it will work. But hey – at least you can work around this.</p>
<p><strong>Conclusion</strong></p>
<p>As much as Web services as a technology are consumer-agnostic, it seems that consumers themselves are pretty religious about what they do. Two different consumption approaches in .NET, and both behave in specific ways, causing you trouble if you don’t pay attention.</p>
<p>Which one would I use? Service Reference, any day. Getting rid of the Order parameter is as simple as this regular expression: <strong>(\s*Order=\d+\s*\,?\s*)|(\,?\s*Order=\d+\s*) </strong>(thanks, same to you, too!) (and yes – please feel free to point out how bat it is or to improve it, it was just impromptued here, I didn’t make any attempt to optimize it)</p>
<p><strong>… and an Appendix</strong></p>
<p>Talking about SOAP, let’s make a soap opera here. I won’t end this Web Reference vs. Service Reference here. I’ve given you two very practical arguments about what’s wrong and what’s not about these two approaches. I’m going to write another post, rather scholarly, where I’ll theorize on some less obvious aspect of a major difference between those two approaches, which actually affects anything that you do, if you want to use generic Web service approach, rather than specifically referencing every Web service you intend to use.</p>
<p>See you soon.</p>
<hr />
Read this post at its original location at <a href="http://navigateintosuccess.com/blog/web-reference-vs-service-reference-part-3">http://navigateintosuccess.com/blog/web-reference-vs-service-reference-part-3</a>, or visit the original blog at <a href="http://navigateintosuccess.com/" title="Navigate Into Success">http://NavigateIntoSuccess.com</a>. 47fc2f5642456dfd71e5581a3785c625<img src="http://feeds.feedburner.com/~r/NavigateIntoSuccess/~4/zjK-3eBqlN4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://navigateintosuccess.com/blog/web-reference-vs-service-reference-part-3/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://navigateintosuccess.com/blog/web-reference-vs-service-reference-part-3</feedburner:origLink></item>
		<item>
		<title>Web Reference vs. Service Reference, Part 2</title>
		<link>http://feedproxy.google.com/~r/NavigateIntoSuccess/~3/rvleo9ZIzN8/web-reference-vs-service-reference-part-2</link>
		<comments>http://navigateintosuccess.com/blog/web-reference-vs-service-reference-part-2#comments</comments>
		<pubDate>Mon, 30 Jan 2012 07:04:49 +0000</pubDate>
		<dc:creator>Vjekoslav Babic</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Bug]]></category>
		<category><![CDATA[Error]]></category>
		<category><![CDATA[Service Reference]]></category>
		<category><![CDATA[SOAP]]></category>
		<category><![CDATA[Web Reference]]></category>
		<category><![CDATA[Web services]]></category>

		<guid isPermaLink="false">http://navigateintosuccess.com/?p=1125</guid>
		<description><![CDATA[A 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 [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><a href="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/01/image7.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" align="right" src="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/01/image_thumb7.png" width="202" height="135" /></a>A 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.</p>
<p>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.</p>
<p>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.</p>
<p><span id="more-1125"></span>
<p>The first scenario which I am going to present doesn’t work if called from a .NET application through a Web Reference approach, while it works quite happily if called through a Service Reference.</p>
<p>Create a new Codeunit, create one single method there, and have it do this:</p>
<p><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="C/AL Example" border="0" alt="C/AL Example" align="left" src="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/01/image8.png" width="200" height="33" /></p>
<p>&#160;</p>
<p>&#160;</p>
<p>If you see from far away that this will fail – you are absolutely right. But the point here is that there are two ways for this code to fail: the right way, and the wrong way.</p>
<p>The right way for this to fail is this:</p>
<p><a href="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/01/image9.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/01/image_thumb8.png" width="400" height="188" /></a></p>
<p>The wrong way for this to fail is if you call through a Web-Referenced Web service.</p>
<p>So, publish the codeunit as a web service, create new Windows Forms application in Visual Studio, and have it call this Web service. You’ll be surprised that the error message you get is something completely different: the error message reads <font color="#000000"><strong>“Response is not well-formed XML.”</strong></font></p>
<p>That’s not what you need, though. And the XML is pretty much well-formed, thank you very much! The InnerException will tell you that there is a problem with source XML, and will specify the allegedly scrambled data which couldn’t be parsed as XML.</p>
<p>A failure is a failure, right? Not quite. The error that this has returned has nothing to do with an error that actually happened. Actually, you don’t have a clue if an error happened. Try changing the demo codeunit you’ve written above into this:</p>
<p><a href="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/01/image10.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/01/image_thumb9.png" width="350" height="150" /></a></p>
<p>If you call Foo2, no runtime error will occur in NAV, and it will either return the last error message or an okay message.</p>
<p>Still, calling it from a Web Reference gives this: <strong>There is an error in XML document (1, 163).</strong></p>
<p>At the same time, calling Foo Service Reference, throws the runtime error: <strong>“You cannot base a date calculation on an undefined date.&#160; Date: 0D Formula: 1&quot;</strong>, whereas calling Foo2 simply returns the expected text, without a runtime error. Just as expected.</p>
<p>So, what went wrong here? We have two different .NET ways of calling the same stuff, yet one fails, and one succeeds.</p>
<p>Taking the postulate from the beginning of this post, that NAV Web service did and returned exactly the same stuff (you can easily verify that by capturing the XML traffic), something must be failing at client side.</p>
<p>That something, in this specific case, is deserialization of XML-encoded binary information.</p>
<p>If you inspect the XML which NAV Web service sent as a response to the SOAP request of either of the approaches above, it included the date formula represented as <strong>1&amp;#x5;</strong>. 1 is the same as it was, it’s the M part which was, internall in NAV, encoded as ASCII character 5, which is unprintable, therefore translated into it’s hexadecimal representation x5, and XML encoded as &amp;#x5;. The problem is that it was properly deserialized in case of a Service Reference, and not understood in case of a Web Reference.</p>
<p>In fact – that’s a problem in .NET itself, not in NAV. If you take the analysis further, you’ll realize that you can’t have any control whatsoever over the deserialization process in case of a Web Reference, as it happens within the SoapClientProtocol class, which is a built-in .NET object. In other words: there is nothing you can do about this.</p>
<p><strong>Conclusion</strong></p>
<p>If, for whatever reason, Web services you are calling return unformmatted DateFormulas or other binary data which would require XML encoding, don’t use Web References as they will not be able to deserialize such information.</p>
<p>The only workaround is to use Service References, which have no issues there.</p>
<hr />
Read this post at its original location at <a href="http://navigateintosuccess.com/blog/web-reference-vs-service-reference-part-2">http://navigateintosuccess.com/blog/web-reference-vs-service-reference-part-2</a>, or visit the original blog at <a href="http://navigateintosuccess.com/" title="Navigate Into Success">http://NavigateIntoSuccess.com</a>. 47fc2f5642456dfd71e5581a3785c625<img src="http://feeds.feedburner.com/~r/NavigateIntoSuccess/~4/rvleo9ZIzN8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://navigateintosuccess.com/blog/web-reference-vs-service-reference-part-2/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://navigateintosuccess.com/blog/web-reference-vs-service-reference-part-2</feedburner:origLink></item>
		<item>
		<title>Web Reference vs. Service Reference, Part 1</title>
		<link>http://feedproxy.google.com/~r/NavigateIntoSuccess/~3/DVMHoBFKgzU/web-reference-vs-service-reference-part-1</link>
		<comments>http://navigateintosuccess.com/blog/web-reference-vs-service-reference-part-1#comments</comments>
		<pubDate>Fri, 27 Jan 2012 16:38:55 +0000</pubDate>
		<dc:creator>Vjekoslav Babic</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Bug]]></category>
		<category><![CDATA[Proxy class]]></category>
		<category><![CDATA[SOAP]]></category>
		<category><![CDATA[Web services]]></category>

		<guid isPermaLink="false">http://navigateintosuccess.com/?p=1115</guid>
		<description><![CDATA[Once 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 [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><a href="http://www.flickr.com/photos/charlesfred/2823810363/"><img style="background-image: none; margin: 0px 0px 0px 8px; padding-left: 0px; padding-right: 0px; display: inline; float: right; padding-top: 0px; border: 0px;" title="Smorgasbord! by Charles Roffey" src="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/01/image_thumb6.png" alt="Smorgasbord! by Charles Roffey" width="202" height="135" align="right" border="0" /></a>Once upon a time, <a title="Freddy's Blog" href="http://blogs.msdn.com/b/freddyk/" target="_blank">Freddy</a> has delivered a great series on <a title="Web Services (tag) on Freddy's Blog" href="http://blogs.msdn.com/b/freddyk/archive/tags/web+services/" target="_blank">connecting to NAV Web Services</a> 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.</p>
<p>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.</p>
<p><span id="more-1115"></span></p>
<p>There are two types of proxy classes, and they get generated through two different technical choices: Web References or Service Reference.</p>
<p>As Freddy explains:</p>
<blockquote><p><strong>Add Web Reference </strong>is a wrapper over <a href="http://msdn.microsoft.com/en-us/library/7h3ystb6(VS.80).aspx">wsdl.exe</a> and can be used to create proxies for .NET 1.1 or 2.0 clients. Of course this means when you are pointing to a WCF service you have to be pointing to an endpoint that uses basicHttpBinding.</p>
<p><strong>Add Service Reference </strong>is a wrapper over <a href="http://msdn.microsoft.com/en-us/library/aa347733.aspx">svcutil.exe</a> and also creates clients proxies. These proxies, however, can only be consumed by .NET 3.5 clients.</p></blockquote>
<p>Beyond that, there are no obvious differences, and neither of them seems to provide an obvious benefit over the other. NAV Web services doesn’t care who consumes them and in which way – so performance on NAV side is not affected by the choice between these two. Difference in performance on client side has never been proven to exist (at least to my knowledge), so as long as dependency on .NET framework being used is the only constraint, you should be safe to go with either of these.</p>
<p>Well, not quite so. There are considerations, and in the next two blog posts I’ll talk about two specific ones, one of which will definitely convince you to use Service Reference approach; and the other one which would have you consider using Web Reference approach instead.</p>
<p>Just in case you wondered if I have completed my “bug theater” series – I have not. What I decided to do is to give it a more practical aspect, and actually talk about Web services in a more generic way, focusing on solutions, rather than problems. So, the series of Web Reference vs. Service Reference will be just that – explanation of practical aspects of NAV Web services consumption, which explains certain issues in NAV Web services, and what effects they have on your choice of the type of proxy classes you’d use.</p>
<p>It’s Friday afternoon, and I want to keep it suspenseful (at least for those few who would read this <img class="wlEmoticon wlEmoticon-smile" style="border-style: none;" src="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/01/wlEmoticon-smile.png" alt="Smile" />) – so see you all on Monday, when you can read about the first type of difference between Service Reference and Web Reference approaches from the point of view of a consumer.</p>
<hr />
Read this post at its original location at <a href="http://navigateintosuccess.com/blog/web-reference-vs-service-reference-part-1">http://navigateintosuccess.com/blog/web-reference-vs-service-reference-part-1</a>, or visit the original blog at <a href="http://navigateintosuccess.com/" title="Navigate Into Success">http://NavigateIntoSuccess.com</a>. 47fc2f5642456dfd71e5581a3785c625<img src="http://feeds.feedburner.com/~r/NavigateIntoSuccess/~4/DVMHoBFKgzU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://navigateintosuccess.com/blog/web-reference-vs-service-reference-part-1/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://navigateintosuccess.com/blog/web-reference-vs-service-reference-part-1</feedburner:origLink></item>
		<item>
		<title>Bug theater in Web services #5</title>
		<link>http://feedproxy.google.com/~r/NavigateIntoSuccess/~3/Eu8giEnkIqk/bug-theater-in-web-services-5</link>
		<comments>http://navigateintosuccess.com/blog/bug-theater-in-web-services-5#comments</comments>
		<pubDate>Mon, 23 Jan 2012 09:38:13 +0000</pubDate>
		<dc:creator>Vjekoslav Babic</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Bug]]></category>
		<category><![CDATA[FixedLayout]]></category>
		<category><![CDATA[Web services]]></category>
		<category><![CDATA[WSDL]]></category>

		<guid isPermaLink="false">http://navigateintosuccess.com/?p=1110</guid>
		<description><![CDATA[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 [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><a href="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/01/image5.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 0px 0px 8px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top: 0px; border-right: 0px; padding-top: 0px" title="My daughter Ema, born January 16th 2012" border="0" alt="My daughter Ema, born January 16th 2012" align="right" src="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/01/image_thumb5.png" width="202" height="152" /></a>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.</p>
<p>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 the time available with my closest and dearest, which I am not sure when I will have next.</p>
<p>It seems that there is life to keep going on, so I’ll now try to be back with my work and my blog.</p>
<p>Let me introduce bug #5: fields within a FixedLayout control.</p>
<p><span id="more-1110"></span>
<p><strong>Problem</strong></p>
<p>If you have Field controls under a Group of type FixedLayout, at any nesting sub-level, such Field controls wouldn’t be accessible through Web services.</p>
<p>It’s simple to repeat: just publish page 151 Customer Statistics as a web service, and you can see that only the fields belonging to the first group (General) are visible in the WSDL, while any fields from Sales group are not present.</p>
<p>Microsoft has confirmed this problem, but as far as I know, no hotfix has been released to fix this specific issue yet.</p>
<p><strong>Workaround</strong></p>
<p>You can argue that there is no need to access Statistics pages through Web services, so this might seem not a big problem after all. However, this is not only about Statistics pages – it is about any kind of pages where FixedLayout is used, and another example is Journals.</p>
<p>For example, you might want to know if your journal balances to 0 before posting – if fields in FixedLayout would be accessible, it would be a simple task. Without it, you have to keep track of it outside NAV, which means that you must implement all NAVs logic about document numbers, balancing accounts, etc.</p>
<p>In any case, there is no straightforward way to access those fields. The workaround we used is to simply create a new group, make it invisible, and re-add all the fields present under a FixedLayout there. This makes all the data in a page accessible to Web services consumers, while hiding them from front-end users (to avoid confusion).</p>
<p>There is a trick here – because hiding something from front-end users is not as simple as setting the Visible property to FALSE. This would still enable users to show it through Customize This Page functionality. But since this has nothing to do with this specific issue, I’ll blog about it when I get to Web services Tips &amp; Tricks part of this series. For now, let’s keep talking about bugs and workarounds.</p>
<hr />
Read this post at its original location at <a href="http://navigateintosuccess.com/blog/bug-theater-in-web-services-5">http://navigateintosuccess.com/blog/bug-theater-in-web-services-5</a>, or visit the original blog at <a href="http://navigateintosuccess.com/" title="Navigate Into Success">http://NavigateIntoSuccess.com</a>. 47fc2f5642456dfd71e5581a3785c625<img src="http://feeds.feedburner.com/~r/NavigateIntoSuccess/~4/Eu8giEnkIqk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://navigateintosuccess.com/blog/bug-theater-in-web-services-5/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://navigateintosuccess.com/blog/bug-theater-in-web-services-5</feedburner:origLink></item>
		<item>
		<title>Bug theater in Web services #4</title>
		<link>http://feedproxy.google.com/~r/NavigateIntoSuccess/~3/saBPb8gPkZw/bug-theater-in-web-services-4</link>
		<comments>http://navigateintosuccess.com/blog/bug-theater-in-web-services-4#comments</comments>
		<pubDate>Mon, 16 Jan 2012 07:00:00 +0000</pubDate>
		<dc:creator>Vjekoslav Babic</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Bug]]></category>
		<category><![CDATA[Company]]></category>
		<category><![CDATA[Multi-tenant]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Web services]]></category>

		<guid isPermaLink="false">http://navigateintosuccess.com/?p=1104</guid>
		<description><![CDATA[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 [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><a href="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/01/image4.png"><img style="background-image: none; margin: 0px 0px 0px 8px; padding-left: 0px; padding-right: 0px; display: inline; float: right; padding-top: 0px; border: 0px;" title="image" src="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/01/image_thumb4.png" alt="image" width="202" height="136" align="right" border="0" /></a>In my country, there’s a saying: “A good horse has a hundred flaws; a bad one has only one.” It’s bad.</p>
<p>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 <a href="http://navigateintosuccess.com/blog/bug-theater-in-web-services-1">the first post in this series</a> – they are great. They are a good horse. A winner.</p>
<p>The reason why I am doing this is because I want to share the problems I encountered over months of working with Web services intensively, as well as the solutions or workarounds I identified.</p>
<p>Today, on the repertoire we have another security-related glitch, which has been confirmed to me by Microsoft, but as far as I know there has not yet been a hotfix for this.</p>
<p>Bug #4: accessing Web services in multi-company scenarios.</p>
<p><span id="more-1104"></span></p>
<p><strong>Problem</strong></p>
<p>This problem might seem similar to the one I blogged about <a href="http://navigateintosuccess.com/blog/bug-theater-in-web-services-3">last time</a>, but it’s not the same thing.</p>
<p>Take a database with multiple companies in it, then add a Windows login which only has company-level access. It may have access to one company, or to all companies (explicitly). It may be SUPER in those companies it has access to, doesn’t matter. What matters is that it must not have database-wide access in any role (meaning no role without company name specified).</p>
<p>Okay, now that you have that user in place, try accessing a Web service. Any Web service.</p>
<p>You’ll get this error: “You do not have permission to read the Company table.”</p>
<p>To make it short: a user without database-wide access cannot use Web services.</p>
<p><strong>Workaround</strong></p>
<p>You might believe you can work around this problem with simple trial and error approach. The error message is pretty useful at this, and you will quickly realize that the only thing you need to do to “fix” the issue is to create a new security role with the following permissions:</p>
<ol>
<li>Table: Company, with Execute permission.</li>
<li>TableData: Company with Read permission.</li>
</ol>
<p>You then assign this role to every user, without specifying which company the role belongs to, and all users will now be able to access all Web services to which they have proper security access through their roles.</p>
<p>However, as <a title="Eric Sevareid (Wikipedia)" href="http://en.wikipedia.org/wiki/Eric_Sevareid" target="_blank">Eric Sevareid</a> said: <em>The chief cause of problems is solutions</em>.</p>
<p>So, if you apply this solution, you’ve created another problem: now every user in the company can see all other companies in the database. Big deal. Or?</p>
<p>In a multi-company database, this might be a real big deal. And it’s twofold:</p>
<ul>
<li>When users try to open another company, they will see all the companies, not only those that they truly have access to. And if they actually try entering one of those that they don’t have any access other than thru this new workaround role, they will get funny “you don’t have permission to this or that” errors.</li>
<li>When you want to hide which other companies are there in the database from users who don’t really need to know this (because this may easily be a privacy issue in multi-tenant scenarios), then you will have a big issue.</li>
</ul>
<p>Okay, let’s be honest: scenarios when there are multiple companies in the same database, and the users must not know which other companies there are apart from their own, are rare.</p>
<p>But still, if it happens that you have one of those rare scenarios, then there is absolutely nothing you can do, but wait for a hotfix.</p>
<p>Does anybody know if it was released yet?</p>
<hr />
Read this post at its original location at <a href="http://navigateintosuccess.com/blog/bug-theater-in-web-services-4">http://navigateintosuccess.com/blog/bug-theater-in-web-services-4</a>, or visit the original blog at <a href="http://navigateintosuccess.com/" title="Navigate Into Success">http://NavigateIntoSuccess.com</a>. 47fc2f5642456dfd71e5581a3785c625<img src="http://feeds.feedburner.com/~r/NavigateIntoSuccess/~4/saBPb8gPkZw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://navigateintosuccess.com/blog/bug-theater-in-web-services-4/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		<feedburner:origLink>http://navigateintosuccess.com/blog/bug-theater-in-web-services-4</feedburner:origLink></item>
		<item>
		<title>Bug theater in Web services #3</title>
		<link>http://feedproxy.google.com/~r/NavigateIntoSuccess/~3/dNfwJvjeRBs/bug-theater-in-web-services-3</link>
		<comments>http://navigateintosuccess.com/blog/bug-theater-in-web-services-3#comments</comments>
		<pubDate>Fri, 13 Jan 2012 09:24:28 +0000</pubDate>
		<dc:creator>Vjekoslav Babic</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Bug]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[SUPER]]></category>
		<category><![CDATA[Web services]]></category>

		<guid isPermaLink="false">http://navigateintosuccess.com/?p=1100</guid>
		<description><![CDATA[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 [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><a href="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/01/image2.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px 0px 0px 8px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" align="right" src="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/01/image_thumb2.png" width="202" height="137" /></a><a title="Got C/AL" href="http://gotcal.com/" target="_blank">Soren</a> has taught me yesterday that <a title="Bug theater in Web services #2" href="/blog/bug-theater-in-web-services-2">some of the bugs</a> I encountered have been <a title="An invalid date error occurs when you try to send a blank date to Microsoft Dynamics NAV 2009 through web services" href="https://mbs2.microsoft.com/Knowledgebase/KBDisplay.aspx?scid=kb$en-us$2606541" target="_blank">properly disinsected</a> by Microsoft, so other than the workarounds I suggested, there is an option to apply the hotfix and forget about that one.</p>
<p>Today, I’ll explain a not so critical bug, as the one yesterday, but depending on what exactly you do with Web services, it may be more than just a nuisance.</p>
<p>Hello, bug #3: accessing WSDL without database-wide permissions.</p>
<p><span id="more-1100"></span>
<p><strong>Problem</strong></p>
<p>This one is very simple to repeat, and you don’t need any coding. You simply need to have a Windows login which only has roles assigned for a single company.</p>
<p>Follow these steps:</p>
<ol>
<li>Add a Windows login to your NAV database, assign it to SUPER role, and specify company for that role. For example:     <br /><a href="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/01/image3.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top: 0px; border-right: 0px; padding-top: 0px" title="Screenshot: SUPER role for a single company" border="0" alt="Screenshot: SUPER role for a single company" align="right" src="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/01/image_thumb3.png" width="460" height="239" /></a></li>
<li>Synchronize the login, if necessary.</li>
<li>Publish a page as a Web service, say 21 Customer Card, call it whatever</li>
<li>Restart the NST (the Web services part).</li>
<li>Open the browser as the user you defined in step 1.</li>
<li>Navigate to the WSDL of the Web service defined in step 3, e.g. <a href="http://localhost:7047/DynamicsNAV/WS/Page/Customer">http://localhost:7047/DynamicsNAV/WS/Page/Customer</a></li>
</ol>
<p>At this point, this is what the server returns: “The remote server returned an error: (500) Internal Server Error.”</p>
<p>Now do a funny thing. Access the same Web service, but as a user who has database-wide SUPER role (SUPER without a company name specified).</p>
<p>Now you get WSDL as expected.</p>
<p>Now repeat the same as the user with only company-level SUPER role. Guess what – no more errors. The server happily returns the WSDL.</p>
<p>So, a one-sentence description of symptoms is this: a user with only company-level access cannot read WSDL of a Web service unless a user with database-wide SUPER access has previously read the WSDL of the same service.</p>
<p>I can’t tell exactly what’s happening under the hood, but I imagine it’s some security glitch which prevents the user to read WSDL unless the user has database-wide SUPER access. If a database-wide SUPERman has already read the WSDL, it seems to be cached, and returned to anybody else from cache, regardless of their security permission.</p>
<p>So, it may be that accessing WSDL without database-wide SUPER role is prohibited by design, in which case WSDL shouldn’t be returned from cache. Or it may be that anybody should read the WSDL as long as they have proper access to the underlying object(s), in which case there is a bug in returning the WSDL back to the user.</p>
<p>In any case, not good.</p>
<p><strong>Workaround</strong></p>
<p>Well, there is none I could identify. The only thing you can do is access WSDL as a superman, then consuming the service as whoever.</p>
<p>However… (there must be a however)</p>
<p>What if you had a generic application (and I know of at least three of such) which must access WSDL in runtime, and that WSDL might be accessed by a mere mortal?</p>
<p>There are several possible options:</p>
<ol>
<li>If objects are not expected to change, access WSDL once for each needed service during setup, and cache the WSDL description.</li>
<li>If objects are expected to change, create a Windows service which runs as a superman, and accesses WSDL on behalf of mortals.</li>
<li>As an alternative to above, you may store credentials of a superman (of course, you should use some strong encryption here, e.g. the one Windows uses for storing credentials of Windows services), then if reading of the WSDL fails for the error seen earlier, you retry as superman and see if it works.</li>
<li>Despair.</li>
</ol>
<p>I understand this might not be a big problem for most of Web services applications, primarily those that are custom-built for a single customer. But if you have any ISV application which is not specific to an installation, but can run under many different installations of NAV, then this problem might hurt you a bit, in which case I hope you read this post before you actually deploy the application to hundreds of customers.</p>
<p>If you have some thoughts about this problem, or are aware of a hotfix which solves it, please contribute.</p>
<hr />
Read this post at its original location at <a href="http://navigateintosuccess.com/blog/bug-theater-in-web-services-3">http://navigateintosuccess.com/blog/bug-theater-in-web-services-3</a>, or visit the original blog at <a href="http://navigateintosuccess.com/" title="Navigate Into Success">http://NavigateIntoSuccess.com</a>. 47fc2f5642456dfd71e5581a3785c625<img src="http://feeds.feedburner.com/~r/NavigateIntoSuccess/~4/dNfwJvjeRBs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://navigateintosuccess.com/blog/bug-theater-in-web-services-3/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://navigateintosuccess.com/blog/bug-theater-in-web-services-3</feedburner:origLink></item>
		<item>
		<title>Bug theater in Web services #2</title>
		<link>http://feedproxy.google.com/~r/NavigateIntoSuccess/~3/9TOSVh2j25o/bug-theater-in-web-services-2</link>
		<comments>http://navigateintosuccess.com/blog/bug-theater-in-web-services-2#comments</comments>
		<pubDate>Thu, 12 Jan 2012 09:16:41 +0000</pubDate>
		<dc:creator>Vjekoslav Babic</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Bug]]></category>
		<category><![CDATA[RecordID]]></category>
		<category><![CDATA[RecordRef]]></category>
		<category><![CDATA[Web services]]></category>

		<guid isPermaLink="false">http://navigateintosuccess.com/?p=1092</guid>
		<description><![CDATA[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 [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><a href="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/01/image1.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; float: right; padding-top: 0px; border: 0px;" title="image" src="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/01/image_thumb1.png" alt="image" width="202" height="130" align="right" border="0" /></a>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.</p>
<p>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.</p>
<p>So, here comes bug #2: setting a date to 0D.</p>
<p><span id="more-1092"></span></p>
<p><strong>Problem</strong></p>
<p>Try it. Expose a page, which includes a date field, as a web service, then try setting it to 0D value. No way you can do it.</p>
<p>Consider this:</p>
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">SalesOrder_Service svc = <span style="color: #0000ff;">new</span> SalesOrder_Service();</pre>
<pre id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">svc.UseDefaultCredentials();</pre>
<pre id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">SalesOrder order = svc.Read("1000");</pre>
<pre id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">order.Posting_Date = DateTime.MinValue;</pre>
<pre id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">order.Posting_DateSpecified = <span style="color: #0000ff;">true</span>;</pre>
<pre id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">svc.Update(<span style="color: #0000ff;">ref</span> order);</pre>
<p>&nbsp;</p>
</div>
<p>This won’t work, and yet, it’s the equivalent of writing this in C/AL:</p>
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">SalesHeader.VALIDATE("Posting Date",0D);</pre>
<p>&nbsp;</p>
<p>Of course, this works in C/AL. Why it doesn’t work when invoked through Web services, beats me. NAV simply keeps the value as it was earlier. So, once you write a date, it’s there to stay.</p>
</div>
<p><strong>Workaround</strong></p>
<p>Well, obviously you’ll need to write some kind of a function which you can call, and tell it which date field in which table, for which record, should be set to 0D. But as there are a hundred ways to skin a cat (no animals were harmed during writing of this post), there are a hundred ways to set a date to 0D.</p>
<p>One of the obvious ones might be to publish a codeunit with a method which receives the RecordID of the row which must be updated, and the ID of the date field which must be set to 0D. This seems the simplest, because it’s easy to pass the RecordID (thanks to GetRecIdFromKey method of any page Web service), and it could be generic – covering all date fields of all tables with a single function.</p>
<p>Then this piece of code would do the trick:</p>
<div id="codeSnippetWrapper">
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #008000;">// RecID is a RecordID variable</span></pre>
<pre id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #008000;">// tRecID is a text parameter</span></pre>
<pre id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">EVALUATE(RecID,tRecID);</pre>
<pre id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">RecRef := RecID.GETRECORD;</pre>
<pre id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #008000;">// iFldID is an integer parameter</span></pre>
<pre id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="font-size: 8pt; line-height: 12pt;">FldRef := RecRef.FIELD(iFldID);</span></pre>
<pre id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="font-size: 8pt; line-height: 12pt;">FldRef.VALIDATE(0D);</span></pre>
<pre id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="font-size: 8pt; line-height: 12pt;">RecRef.MODIFY;</span></pre>
<p>&nbsp;</p>
</div>
</div>
<p>Well, at least, it will do <em><strong>a</strong></em> trick. Not the one you expected, though.</p>
<p>Trust me, you are not ready for what this thing will do to your data. It will set the date to 0D alright, but it will also reset all the non-key fields of the record to their default values. Now that’s something.</p>
<p>So, that having been eliminated, what else can you do?</p>
<p>You could try with RecordRef, creating a more complex way to tell this generic function which date field in which table you want to update, and for which record, because – interestingly – the code above wouldn’t make a mess if RecordRef was obtained through GETTABLE or OPEN functions. It only happens if it was obtained through RecordID.</p>
<p>In <a title="Stratus" href="/tags/stratus">Stratus</a>, we didn’t want to gamble with RecordRef for 0D, so we’ve skinned the cat a different way around. We’ve utilized our extension codeunit builder, and automatically built an extension codeunit which has as many functions as there are date fields that we wanted to update, each of which explicitly sets this or that specific date field in this or that specific table to 0D.</p>
<p>If you have a better workaround, please don’t be shy, share it here (or elsewhere).</p>
<hr />
Read this post at its original location at <a href="http://navigateintosuccess.com/blog/bug-theater-in-web-services-2">http://navigateintosuccess.com/blog/bug-theater-in-web-services-2</a>, or visit the original blog at <a href="http://navigateintosuccess.com/" title="Navigate Into Success">http://NavigateIntoSuccess.com</a>. 47fc2f5642456dfd71e5581a3785c625<img src="http://feeds.feedburner.com/~r/NavigateIntoSuccess/~4/9TOSVh2j25o" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://navigateintosuccess.com/blog/bug-theater-in-web-services-2/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		<feedburner:origLink>http://navigateintosuccess.com/blog/bug-theater-in-web-services-2</feedburner:origLink></item>
		<item>
		<title>Bug theater in Web services #1</title>
		<link>http://feedproxy.google.com/~r/NavigateIntoSuccess/~3/pCxUYl19oMg/bug-theater-in-web-services-1</link>
		<comments>http://navigateintosuccess.com/blog/bug-theater-in-web-services-1#comments</comments>
		<pubDate>Wed, 11 Jan 2012 13:24:12 +0000</pubDate>
		<dc:creator>Vjekoslav Babic</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Bug]]></category>
		<category><![CDATA[Stratus]]></category>
		<category><![CDATA[Web services]]></category>

		<guid isPermaLink="false">http://navigateintosuccess.com/blog/bug-theater-in-web-services-1</guid>
		<description><![CDATA[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 [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><a href="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/01/image.png"><img style="background-image: none; margin: 0px 0px 0px 8px; padding-left: 0px; padding-right: 0px; display: inline; float: right; padding-top: 0px; border: 0px;" title="image" src="http://navigateintosuccess.fortempodoo.netdna-cdn.com/wp-content/uploads/2012/01/image_thumb.png" alt="image" width="202" height="134" align="right" border="0" /></a>If something, <a title="Stratus" href="/tags/stratus">Stratus</a> 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.</p>
<p>Being buggy doesn’t mean it doesn’t work. It only means you need to twist and bend your code to achieve things which you would expect to work out of the box. During development of Stratus, we had to make a series of workarounds in Web services to achieve simple goals, and I decided to share those bugs (and workarounds) with you, to help you be more productive in your Web services based projects.</p>
<p>So, here we go for bug #1: lowercase codes in primary key.</p>
<p><span id="more-1087"></span></p>
<p><strong>Problem</strong></p>
<p>Check this out:</p>
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">Customer_Service svc = <span style="color: #0000ff;">new</span> Customer_Service();</pre>
<pre id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">svc.UseDefaultCredentials = <span style="color: #0000ff;">true</span>;</pre>
<pre id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">Customer cust = <span style="color: #0000ff;">new</span> Customer { No = <span style="color: #006080;">"test"</span> };</pre>
<pre id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">svc.Create(<span style="color: #0000ff;">ref</span> cust);</pre>
<p>&nbsp;</p>
<p>(I assume I don’t need to give details about how to configure the Web reference in C# or how to expose page 21 Customer Card as a Web service called Customer.)</p>
</div>
<div> Now, imagine you write this code in your OnRename trigger in table 18 Customer:</div>
<div id="codeSnippetWrapper">
<pre id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">ERROR('Gotcha %1!',"No.");</pre>
<p>&nbsp;</p>
<p>Guess what happens?</p>
</div>
<p>Well, you get the ‘Gotcha!’ error. Inserting a lowercase value into a code field actually first insert the lowercase value, then renames it to an uppercase value. Pretty cool, eh?</p>
<p>Funny thing – this cannot be done through RTC. OnRename never gets triggered if you insert a lowercase code value to a key field through RTC. This is how Web services should actually behave as well.</p>
<p><strong>Workaround</strong></p>
<p>Not much you can do here. Make sure you uppercase your codes before shipping them over to NAV. RTC seems to do just that.</p>
<hr />
Read this post at its original location at <a href="http://navigateintosuccess.com/blog/bug-theater-in-web-services-1">http://navigateintosuccess.com/blog/bug-theater-in-web-services-1</a>, or visit the original blog at <a href="http://navigateintosuccess.com/" title="Navigate Into Success">http://NavigateIntoSuccess.com</a>. 47fc2f5642456dfd71e5581a3785c625<img src="http://feeds.feedburner.com/~r/NavigateIntoSuccess/~4/pCxUYl19oMg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://navigateintosuccess.com/blog/bug-theater-in-web-services-1/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://navigateintosuccess.com/blog/bug-theater-in-web-services-1</feedburner:origLink></item>
	</channel>
</rss><!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic (Feed is rejected)
Page Caching using disk: enhanced
Database Caching 1/82 queries in 0.341 seconds using disk: basic
Object Caching 2242/2464 objects using disk: basic
Content Delivery Network via navigateintosuccess.fortempodoo.netdna-cdn.com

Served from: navigateintosuccess.com @ 2012-05-24 03:10:21 -->

