<?xml version="1.0" encoding="UTF-8" standalone="yes"?><oembed><version><![CDATA[1.0]]></version><provider_name><![CDATA[AnttiTech]]></provider_name><provider_url><![CDATA[https://anttitech.wordpress.com]]></provider_url><author_name><![CDATA[Antti Makkonen]]></author_name><author_url><![CDATA[https://anttitech.wordpress.com/author/anttitech/]]></author_url><title><![CDATA[Things I learned building OData service to Azure and using WP7 as&nbsp;client]]></title><type><![CDATA[link]]></type><html><![CDATA[<p>I wanted to build an Windows Phone 7 app called “Stuff I Like”. App would have OData service running in Azure and client that would cache and sync to that service. In previous post I wrote about stuff that I learned building the WP7 app. In this part I will reveal my findings on the service side of things. In the next post I will dwell into Authentication side of the app.</p>
<p>If you are planning to add Federated Authentication using Azure Access Control service then you might want to start by building authentication first. For me it was waaaay easier to add normal aps web page add authentication to that and add WCF data service after login worked. For you I would recommend downloading Azure Training Kit: <a href="http://www.microsoft.com/en-us/download/details.aspx?id=8396">http://www.microsoft.com/en-us/download/details.aspx?id=8396</a> and completing Lab Exercise <a href="http://msdn.microsoft.com/en-us/identitytrainingcourse_acsandwindowsphone7.aspx">http://msdn.microsoft.com/en-us/identitytrainingcourse_acsandwindowsphone7.aspx</a></p>
<p>Now back to business.</p>
<p>When I followed this Data service in the cloud <a href="http://msdn.microsoft.com/en-us/data/gg192994">http://msdn.microsoft.com/en-us/data/gg192994</a>. I decided to design the data model using visual studio design tool. After playing a round with the tool I managed to &#8220;draw&#8221; data model and after that it was just a matter of syncing it to Database.</p>
<div data-shortcode="caption" id="attachment_260" style="width: 310px" class="wp-caption aligncenter"><a href="https://anttitech.files.wordpress.com/2012/06/stuff-i-like-dataservice.jpg"><img loading="lazy" aria-describedby="caption-attachment-260" data-attachment-id="260" data-permalink="https://anttitech.wordpress.com/2012/06/27/things-i-learned-building-odata-service-to-azure-and-using-wp7-as-client/stuff-i-like-dataservice/" data-orig-file="https://anttitech.files.wordpress.com/2012/06/stuff-i-like-dataservice.jpg" data-orig-size="725,627" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Antti Makkonen&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1340805782&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}" data-image-title="Stuff I Like datamodel" data-image-description="" data-image-caption="&lt;p&gt;This is how I draw the data model&lt;/p&gt;
" data-medium-file="https://anttitech.files.wordpress.com/2012/06/stuff-i-like-dataservice.jpg?w=300" data-large-file="https://anttitech.files.wordpress.com/2012/06/stuff-i-like-dataservice.jpg?w=725" class="size-medium wp-image-260" title="Stuff I Like datamodel" src="https://anttitech.files.wordpress.com/2012/06/stuff-i-like-dataservice.jpg?w=300&#038;h=259" alt="" width="300" height="259" srcset="https://anttitech.files.wordpress.com/2012/06/stuff-i-like-dataservice.jpg?w=300&amp;h=259 300w, https://anttitech.files.wordpress.com/2012/06/stuff-i-like-dataservice.jpg?w=600&amp;h=518 600w, https://anttitech.files.wordpress.com/2012/06/stuff-i-like-dataservice.jpg?w=150&amp;h=130 150w" sizes="(max-width: 300px) 100vw, 300px" /></a><p id="caption-attachment-260" class="wp-caption-text">This is how I draw the data model</p></div>
<p>After syncing above data model into database, setting up the service and running it I quickly found that my WCF Data Services where not working at all. Message “The server encountered an error processing the request. See server logs for more details.” was shown to me quite frequently. Well &#8220;the bug&#8221; was quite simple to fix and these debugging instructions helped me a lot <a href="http://www.bondigeek.com/blog/2010/12/11/debugging-wcf-data-services">http://www.bondigeek.com/blog/2010/12/11/debugging-wcf-data-services</a>:</p>
<ol>
<li>A missing SetEntitySetAccessRule</li>
<li>A missing pluralisation on the SetEntitySetAccessRule</li>
<li>A missing SetServiceOperationAccessRule</li>
</ol>
<p>After Debugged EntityAccessRules with simple “*” allowRead just to check that I had not made a typo I quickly found out that I indeed had 😦 So I after I fixed a typo in EdmRelationshipAttribute and it caused the exception. After that stupid mistake things started to look better.</p>
<p>If you need more instructions on how to turn on debugging messages then just follow these instructions:</p>
<ul>
<li><a href="http://blogs.msdn.com/b/phaniraj/archive/2008/06/18/debugging-ado-net-data-services.aspx">http://blogs.msdn.com/b/phaniraj/archive/2008/06/18/debugging-ado-net-data-services.aspx</a></li>
<li><a href="http://blogs.msdn.com/b/tconte/archive/2010/09/07/wcf-data-services-odata-et-georss.aspx">http://blogs.msdn.com/b/tconte/archive/2010/09/07/wcf-data-services-odata-et-georss.aspx</a></li>
</ul>
<div data-shortcode="caption" id="attachment_259" style="width: 550px" class="wp-caption aligncenter"><a href="https://anttitech.files.wordpress.com/2012/06/code-from-stuff-i-like-web-server.jpg"><img loading="lazy" aria-describedby="caption-attachment-259" data-attachment-id="259" data-permalink="https://anttitech.wordpress.com/2012/06/27/things-i-learned-building-odata-service-to-azure-and-using-wp7-as-client/code-from-stuff-i-like-web-server/" data-orig-file="https://anttitech.files.wordpress.com/2012/06/code-from-stuff-i-like-web-server.jpg" data-orig-size="799,463" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Antti Makkonen&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1340805667&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}" data-image-title="Code from stuff i like web server" data-image-description="" data-image-caption="&lt;p&gt;This is how my service looked after I finally got it running &lt;/p&gt;
" data-medium-file="https://anttitech.files.wordpress.com/2012/06/code-from-stuff-i-like-web-server.jpg?w=300" data-large-file="https://anttitech.files.wordpress.com/2012/06/code-from-stuff-i-like-web-server.jpg?w=799" class="size-full wp-image-259" title="Code from stuff i like web server" src="https://anttitech.files.wordpress.com/2012/06/code-from-stuff-i-like-web-server.jpg?w=540&#038;h=312" alt="" width="540" height="312" srcset="https://anttitech.files.wordpress.com/2012/06/code-from-stuff-i-like-web-server.jpg?w=538&amp;h=312 538w, https://anttitech.files.wordpress.com/2012/06/code-from-stuff-i-like-web-server.jpg?w=150&amp;h=87 150w, https://anttitech.files.wordpress.com/2012/06/code-from-stuff-i-like-web-server.jpg?w=300&amp;h=174 300w, https://anttitech.files.wordpress.com/2012/06/code-from-stuff-i-like-web-server.jpg?w=768&amp;h=445 768w, https://anttitech.files.wordpress.com/2012/06/code-from-stuff-i-like-web-server.jpg 799w" sizes="(max-width: 540px) 100vw, 540px" /></a><p id="caption-attachment-259" class="wp-caption-text">This is how my service looked after I finally got it running</p></div>
<p>After I managed to get service defined and running I took a second to make OData feed a bit more readable so that you can consume your OData feed using Explorer and other browsers. <a href="http://msdn.microsoft.com/en-us/library/ee373839.aspx">http://msdn.microsoft.com/en-us/library/ee373839.aspx</a></p>
<div data-shortcode="caption" id="attachment_256" style="width: 310px" class="wp-caption aligncenter"><a href="https://anttitech.files.wordpress.com/2012/06/before.jpg"><img loading="lazy" aria-describedby="caption-attachment-256" data-attachment-id="256" data-permalink="https://anttitech.wordpress.com/2012/06/27/things-i-learned-building-odata-service-to-azure-and-using-wp7-as-client/before/" data-orig-file="https://anttitech.files.wordpress.com/2012/06/before.jpg" data-orig-size="1200,476" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Antti Makkonen&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1340805108&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}" data-image-title="OData feed before changes" data-image-description="" data-image-caption="&lt;p&gt;This is how OData feed looks before you tweak it a bit.&lt;/p&gt;
" data-medium-file="https://anttitech.files.wordpress.com/2012/06/before.jpg?w=300" data-large-file="https://anttitech.files.wordpress.com/2012/06/before.jpg?w=1024" class="size-medium wp-image-256 " title="OData feed before changes" src="https://anttitech.files.wordpress.com/2012/06/before.jpg?w=300&#038;h=119" alt="" width="300" height="119" srcset="https://anttitech.files.wordpress.com/2012/06/before.jpg?w=300&amp;h=119 300w, https://anttitech.files.wordpress.com/2012/06/before.jpg?w=600&amp;h=238 600w, https://anttitech.files.wordpress.com/2012/06/before.jpg?w=150&amp;h=60 150w" sizes="(max-width: 300px) 100vw, 300px" /></a><p id="caption-attachment-256" class="wp-caption-text">This is how OData feed looks before you tweak it a bit.</p></div>
<p>For some reason I managed to first add “m:FC_TargetPath” and similar properties to wrong xml element. So make sure you scroll down the file and add it to correct place 🙂</p>
<div data-shortcode="caption" id="attachment_257" style="width: 310px" class="wp-caption aligncenter"><a href="https://anttitech.files.wordpress.com/2012/06/after.jpg"><img loading="lazy" aria-describedby="caption-attachment-257" data-attachment-id="257" data-permalink="https://anttitech.wordpress.com/2012/06/27/things-i-learned-building-odata-service-to-azure-and-using-wp7-as-client/after/" data-orig-file="https://anttitech.files.wordpress.com/2012/06/after.jpg" data-orig-size="1185,340" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Antti Makkonen&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1340805166&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}" data-image-title="OData feed after changes" data-image-description="" data-image-caption="&lt;p&gt;This is how OData feed will look when you tweak it a bit&lt;/p&gt;
" data-medium-file="https://anttitech.files.wordpress.com/2012/06/after.jpg?w=300" data-large-file="https://anttitech.files.wordpress.com/2012/06/after.jpg?w=1024" class="size-medium wp-image-257" title="OData feed after changes" src="https://anttitech.files.wordpress.com/2012/06/after.jpg?w=300&#038;h=86" alt="" width="300" height="86" srcset="https://anttitech.files.wordpress.com/2012/06/after.jpg?w=300&amp;h=86 300w, https://anttitech.files.wordpress.com/2012/06/after.jpg?w=600&amp;h=172 600w, https://anttitech.files.wordpress.com/2012/06/after.jpg?w=150&amp;h=43 150w" sizes="(max-width: 300px) 100vw, 300px" /></a><p id="caption-attachment-257" class="wp-caption-text">This is how OData feed will look when you tweak it a bit</p></div>
<p>Another thing that took me couple of hours to figure out was that Explorer does not show all OData results in consistent way. So before you start heavily debugging check the returned html page source code and you should see expected result in XML format. OR you could use another browser. For example this call did not seem to return anything <span style="text-decoration:underline;"><a href="http://localhost:57510/WcfDataServiceStuffILike.svc/StuffSet(guid'cf1bfd2f-99f3-4047-99f8-22bc1aad1b99')/GategorySet">http://localhost:57510/WcfDataServiceStuffILike.svc/StuffSet(guid&#8217;cf1bfd2f-99f3-4047-99f8-22bc1aad1b99&#8242;)/GategorySet</a></span> until I checked the source code of this page.</p>
<p>So that’s it. Using Visual Studio this was quite easy and I actually spent most of my time figuring out why some configuration did not work than making the code.  This might be due to the fact that I have “unclean” dev environment or I made lots of changes to above demos while I followed them. This was mainly due to the fact that I wanted to build my own app and not simply type in demos and labs.</p>
<p>I bet If you build your dev environment correctly and follow the labs and demos to the letter you won’t see as many problems that I witnessed. But where is the fun in that 😉</p>
]]></html><thumbnail_url><![CDATA[https://anttitech.files.wordpress.com/2012/06/stuff-i-like-dataservice.jpg?w=300&fit=440%2C330]]></thumbnail_url><thumbnail_width><![CDATA[]]></thumbnail_width><thumbnail_height><![CDATA[]]></thumbnail_height></oembed>