Machine Learning Authors: Zakia Bouachraoui, Liz McMillan, Roger Strukhoff, Pat Romanski, Carmen Gonzalez

Related Topics: Linux Containers, Microsoft Cloud, Machine Learning

Linux Containers: Article

How To Create a Silverlight App That Consumes a POX Service

First off, it might be worth it to note that there is a Silverlight 'Quick Start' for performing this task

Kevin Hoffman's Blog

I realize that it might be a little early to evaluate the overall experience of doing something like this on a piece of Alpha software, but, I figure if Microsoft is going to assault the developer community with so many betas, alphas, gammas, zetas, and whatever else they can find - its my right as a developer to try out every last one of those products, alpha or otherwise.

First off, it might be worth it to note that there is a Silverlight "Quick Start" for performing this task. The problem is that the Quick Start sucks. It actually tells you to go off and follow the directions for creating a basic ASP.NET Web Service - which is wrong. In order to do this, you need to create a POX service using Orcas, not a WSDL-spewing bloat machine like the default ASP.NET .asmx services.

The key to creating a POX service with Orcas are a couple of attributes that I only wish were available right now in non-Orcas web services. First, you need to decorate your code-behind Web Service class as such:


Secondly, for each method that you want to be accessible to scripts, you need to configure that method appropriate. It needs the standard WebMethod attribute, but it can also take another one:


This allows your method to be accessed by scripts (no envelopes, just POX), and also informs the web service factory handler that this method is available through HTTP GET requests. At this point, you're probably thinking, "Yay! I've got a POX service!" ... well, almost. Something else that I didn't find in the Quick Starts is that the HTTP POST and HTTP GET protocols are not enabled by ASP.NET web services by default, you have to enable them in your web.config file with the following XML:

            <add name="HttpGet"/>
            <add name="HttpPost"/>

Now you actually have a POX service that is capable of returning some useful data to your AJAX scripts or, more currently, to your Silverlight Application.

I'll spare you the gorey details of creating the Silverlight application, and creating the ASP.NET "Silverlight link" that will copy the output files of your Silverlight app into your ASP.NET app for building, and just show you the code that I used to consume a simple POX data service method that returns a string. The output of the string is, in typical 'hello world' fashion, used to modify the contents of a TextBlock control:

public void HandleClick(object o, EventArgs e)
    BrowserHttpWebRequest req = new Browser
HttpWebRequest(new Uri(

    HttpWebResponse response = req.GetResponse();
    StreamReader responseReader = new 
    string rawResponse = responseReader.
    XmlReader xr = XmlReader.Create(new
    labelText.Text = xr.Value;

So with all this in place, you can now create your XAML and have something like MouseLeftButtonUp (remember that you don't have Click (yet) in Silverlight..) invoke the POX service, get the data, and then repopulate data elements dynamically at runtime.

The next step here is to obviously do the call to the web service asynchronously (which is entirely possible, and actually pretty easy). I think the next thing I'm going to do as an experiment is to have the code in the Silverlight app modify an HTML element so that it changes to indicate that a data connection is being made in the background. Once the data is retrieved, the HTML element will be set back to normal and the data from the service will be used to populate some controls on the page. We'll see how that turns out :)

links: digg this  del.icio.us  technorati  reddit

More Stories By Kevin Hoffman

Kevin Hoffman, editor-in-chief of SYS-CON's iPhone Developer's Journal, has been programming since he was 10 and has written everything from DOS shareware to n-tier, enterprise web applications in VB, C++, Delphi, and C. Hoffman is coauthor of Professional .NET Framework (Wrox Press) and co-author with Robert Foster of Microsoft SharePoint 2007 Development Unleashed. He authors The .NET Addict's Blog at .NET Developer's Journal.

Comments (1)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.

CloudEXPO Stories
The precious oil is extracted from the seeds of prickly pear cactus plant. After taking out the seeds from the fruits, they are adequately dried and then cold pressed to obtain the oil. Indeed, the prickly seed oil is quite expensive. Well, that is understandable when you consider the fact that the seeds are really tiny and each seed contain only about 5% of oil in it at most, plus the seeds are usually handpicked from the fruits. This means it will take tons of these seeds to produce just one bottle of the oil for commercial purpose. But from its medical properties to its culinary importance, skin lightening, moisturizing, and protection abilities, down to its extraordinary hair care properties, prickly seed oil has got lots of excellent rewards for anyone who pays the price.
The platform combines the strengths of Singtel's extensive, intelligent network capabilities with Microsoft's cloud expertise to create a unique solution that sets new standards for IoT applications," said Mr Diomedes Kastanis, Head of IoT at Singtel. "Our solution provides speed, transparency and flexibility, paving the way for a more pervasive use of IoT to accelerate enterprises' digitalisation efforts. AI-powered intelligent connectivity over Microsoft Azure will be the fastest connected path for IoT innovators to scale globally, and the smartest path to cross-device synergy in an instrumented, connected world.
There are many examples of disruption in consumer space – Uber disrupting the cab industry, Airbnb disrupting the hospitality industry and so on; but have you wondered who is disrupting support and operations? AISERA helps make businesses and customers successful by offering consumer-like user experience for support and operations. We have built the world’s first AI-driven IT / HR / Cloud / Customer Support and Operations solution.
ScaleMP is presenting at CloudEXPO 2019, held June 24-26 in Santa Clara, and we’d love to see you there. At the conference, we’ll demonstrate how ScaleMP is solving one of the most vexing challenges for cloud — memory cost and limit of scale — and how our innovative vSMP MemoryONE solution provides affordable larger server memory for the private and public cloud. Please visit us at Booth No. 519 to connect with our experts and learn more about vSMP MemoryONE and how it is already serving some of the world’s largest data centers. Click here to schedule a meeting with our experts and executives.
Darktrace is the world's leading AI company for cyber security. Created by mathematicians from the University of Cambridge, Darktrace's Enterprise Immune System is the first non-consumer application of machine learning to work at scale, across all network types, from physical, virtualized, and cloud, through to IoT and industrial control systems. Installed as a self-configuring cyber defense platform, Darktrace continuously learns what is ‘normal' for all devices and users, updating its understanding as the environment changes.