Consume .NET services without Silverlight

Adobe Flex comes through

Providing a secure and efficient Helpdesk

Web bling tone Can Adobe Systems' Flex access Microsoft .NET web services? Adobe tends to promote its own ColdFusion or LiveCycle Data Services for use with Flex, but it also has support for SOAP 1.1.

When Microsoft released Silverlight 2 second beta last month, I tested it by building a simple Create, Retrieve, Update, Delete (CRUD) database application, following all the defaults: SQL Server, ASP.NET, Windows Communication Foundation (WCF) web service, and of course Visual Studio 2008 to bring it all together. It wasn't entirely painless, but the problems were largely in getting Microsoft's beta tools to install correctly; in the end it worked well.

I could not resist trying Flex with the same web service. Since I had used the BasicHttpBinding for the WCF service, it should be compatible. How easy would it be? It is a key point for developers on Microsoft's platform who may be eyeing Flex or AIR with interest.

I installed my web service into IIS 7.0 and tested it. It is a simple affair, designed to be the back end for a rudimentary guestbook. There is a GuestItem class, which represents an entry in the book, and a web service with three methods: GetGuestEntries, SaveGuestItem and DeleteGuestItem. I fired up FlexBuilder, created a new Flex web application project, and added a DataGrid and a few other controls that I hoped to populate with my data. Then I chose Import Web Service from the Data menu.

Import WSDL screen grab

Microsoft's web service is sucked into FlexBuilder

FlexBuilder proceeded to generate nearly forty ActionScript files in order to wrap the service. Still, I was in luck: the import worked. Adobe is actually using a modified version of the excellent Apache Axis2, which is encouraging.

The next question was how to talk to the service. I opened GuestBook.as, and was delighted to find comments with code samples, even though they were not quite complete. The basic pattern is this:

1. Create an instance of the web service wrapper class

2. Add a listener that corresponds to the method you will call. The web service is called asynchronously, and the function you supply for the listener will be called when the result is received

3. Add a listener for SOAP faults. This is a kind of exception handler

4. Call the service method

Fortunately these steps only take a few lines of code. Here is the listener function, which binds the list of entries to the DataGrid:

  public function getGuestItemsResult(e:GetGuestItemsResultEvent):void {
        grdGuestBook.dataProvider = e.result;

Here is the code which calls the web service:

   public function refreshGuestList():void {
   var guestService:GuestBook= new GuestBook();

Incidentally, the C# method that implements the service looks like this:

public List<GuestItem> GetGuestItems()

The ActionScript wrapper represents this as a custom class, ArrayOfGuestItem, which extends ArrayCollection, and this binds nicely to a DataGrid. I just needed to set the dataField attribute of each column in the grid to match the properties of a GuestItem.

Internet Security Threat Report 2014

More from The Register

next story
Microsoft on the Threshold of a new name for Windows next week
Rebranded OS reportedly set to be flung open by Redmond
'In... 15 feet... you will be HIT BY A TRAIN' Google patents the SPLAT-NAV
Alert system tips oblivious phone junkies to oncoming traffic
Apple: SO sorry for the iOS 8.0.1 UPDATE BUNGLE HORROR
Apple kills 'upgrade'. Hey, Microsoft. You sure you want to be like these guys?
SMASH the Bash bug! Apple and Red Hat scramble for patch batches
'Applying multiple security updates is extremely difficult'
ARM gives Internet of Things a piece of its mind – the Cortex-M7
32-bit core packs some DSP for VIP IoT CPU LOL
Lotus Notes inventor Ozzie invents app to talk to people on your phone
Imagine that. Startup floats with voice collab app for Win iPhone
prev story


Providing a secure and efficient Helpdesk
A single remote control platform for user support is be key to providing an efficient helpdesk. Retain full control over the way in which screen and keystroke data is transmitted.
Intelligent flash storage arrays
Tegile Intelligent Storage Arrays with IntelliFlash helps IT boost storage utilization and effciency while delivering unmatched storage savings and performance.
Beginner's guide to SSL certificates
De-mystify the technology involved and give you the information you need to make the best decision when considering your online security options.
Security for virtualized datacentres
Legacy security solutions are inefficient due to the architectural differences between physical and virtual environments.
Secure remote control for conventional and virtual desktops
Balancing user privacy and privileged access, in accordance with compliance frameworks and legislation. Evaluating any potential remote control choice.