Update tile notifcation with XML returned by web service

Posted by tempid on Stack Overflow See other posts from Stack Overflow or by tempid
Published on 2012-10-16T00:00:29Z Indexed on 2012/10/16 17:01 UTC
Read the original article Hit count: 370

Filed under:

I have a Metro app in C# & XAML. The tile is updated periodically and I've used WebAPI to serve the tile notification XML. So far so good. I was then told that I cannot use WebAPI as the server that I was planning to host it on does not have .NET 4.5. No plans to install it anytime soon either. I had to change the WebAPI to a plain old Web service (.NET 3.5) which does the same thing - return tile notification XML. I've enabled HTTP-GET (I know, security concern) and was able to invoke the webservice like this -

http://server/TileNotifications.asmx/[email protected]

But ever since I made the switch, the tiles are not being updated. I've checked Fiddler and made sure the app is hitting the webservice and the XML is being returned correctly. But the tiles are not updated. If I replace it with the WebAPI, the tiles are updated.

Do I need to do anything special with the web services? like decorating the web method with a custom attribute? Here's my web service code -

[WebMethod]
        public XmlDocument GetTileData(string user)
        {
           // snip

            var xml = new XmlDocument();
            xml.LoadXml(string.Format(@"<tile>
                                      <visual>
                                        <binding template='TileWideSmallImageAndText02'>
                                          <image id='1' src='http://server/images/{0}_wide.png'/>
                                          <text id='1'>Custom Field : {1}/text>
                                          <text id='2'>Custom Field : {2}</text>
                                          <text id='3'>Custom Field : {3}</text>
                                        </binding>
                                        <binding template='TileSquarePeekImageAndText01'>
                                          <image id='1' src='http://server/images/{0}_square.png'/>
                                          <text id='1'>Custom Field</text>
                                          <text id='2'>{1}</text>
                                        </binding>    
                                      </visual>
                                    </tile>", value1, value2, value3, value4));

            return xml;
        }

© Stack Overflow or respective owner

Related posts about microsoft-metro