WPF Xaml Coexists with Java


Fig 1 Example of 2D WPF OWS Mapping Interface

One of the interesting aspects of XML is its decoupling affect. XML readers and writers can be language and OS agnostic. Adding AJAX to the mix creates some interesting technology interactions. Since Microsoft WPF Xaml is an XML rendering grammar, Xaml can be created using either a Microsoft approach, such as Windows, IIS, SqlServer, C#, ASP, or alternative platforms like LAMP, Linux, Apache, MySQL, PHP or in my case Linux, Apache, PostgreSQL, Java.

The Java language provides some flexibility to the server side. This becomes especially important as virtual systems and utility computing models become more popular. Amazon’s Elastic Compute Cloud, EC2 http://aws.amazon.com/, is an important platform for startups and small businesses. By keeping development in a Linux/Apache based platform a small business can easily take advantage of Amazon’s EC2 instances for low entry cost and then scale to meet traffic fluctuations. EC2/S3 lets the computing platform instances become cash flow dependent rather than a fixed capital investment.

Based on Linux, EC2 is not available for Microsoft technology and servers. Although Microsoft provides Silverlight streaming service http://silverlight.live.com, it is not marketing it as broadly and extensively as Amazon’s EC2/S3 service. Setting up EC2 instances with Mono based C# might be feasible, but adds complexity and is not likely to keep up with the newest tools and technology from Microsoft. Depending on Amazons success with utility computing other large players such as Microsoft, Google, IBM, and governments could enter the utility computing infrastructure field. In the meantime AWS is a significant reason to keep web server options open to Linux/Apache.

The rise of XML makes bridging all the various platforms much easier and robust. WPF Xaml/Xbap applications can be built using Visual Studio and served from any service platform. For instance a WPF XBAP service can be compiled on a Microsoft VS development system, but then served from a Linux server using Apache Tomcat and Java. This means that I can develop the client side using WPF C# taking advantage of all the rich client graphic and 3D capability. I can then create an Xbap for publishing from an Apache web server running on a Linux platform, which in fact can be a virtual EC2 instance. Server side intelligence can take advantage of Java’s flexibility and power.

On the client side, WPF’s power as a rendering engine is extending beyond IE. As .NET rolls up to version 3.5 additional browser support has been added for FireFox and Safari, subsuming the main browser platforms in the world at large. WPF adds another benefit, instead of depending so heavily on CPUs at the server for typical web applications based on ASP, JSP, PHP, Dojo, Java Server Faces etc, the client CPU is pulled into action distributing the workload out across the internet. In spite of the heavier computation involved with WPF, the CPU footprint at the server does not need to scale significantly.

AJAX brings up another interesting development in the web world. Traditional web applications incorporated collections of loosely connected web pages whether server compiled JSP, ASP, PHP, or just plain old html. Web applications generally transmitted state from page to page often using server frameworks like Struts. In contrast AJAX makes monolithic web services feasible providing an alternative to the now familiar page based web applications. Many Ajax oriented sites of course still use some combination of stateless page progression and Ajax calls for specific page functions.

However, AJAX web services can more closely model the application model of development in which one executable controls the workflow, communicating with local computer resources such as databases, storage, and display. In Ajax resources spread across both the client and the cloud. This is important for the continued growth of software as a service, SaaS. Microsoft is apparently in the process of establishing a technology base from which SaaS can evolve. In essence Microsoft hopes to own the technology base undergirding the internet SaaS trend. It is easy to see parallels of this to OS development in the 80s, when Microsoft drove down to the software basement, ignoring hardware, and consequently owned the software superstructure by the end of the following decade.

An Ajax approach is able to send a monolithic web application controller to the client. Then, instead of moving from page to page as the user interacts with the browser, messages are pushed and pulled from the originating server modifying this single browser page. State can be stored in the client and complicated state transmission from page to page is avoided. So for example in Google Maps a single view continues to host user interactions while the view changes according to user actions. The page state progression with annoying refreshes is largely absent. This is all made possible with http calls shuttling back and forth from the monolithic client web page and Google’s server farms.

WPF makes sophisticated views much easier to develop and blurs the interface distinction often found between primitive web applications and traditional applications. Replace javascript, html, and bitmaps with C#, vector rendering, 3D models, and a full complement of interface controls and there are opportunities for much more sophisticated web application interfaces. Much of the power resides in the local rendering while the cloud provides the shared data and communications resources.

One web application I recently worked on illustrates WPF served from Apache Tomcat using AJAX calls to Java to provide a 2D GMTI viewer. This web app allowed user selectable GMTI data displayed on a map background. Once a mission is chosen the map view is adjusted with typical zoom and pan functions using matrix operations in WPF C# that take advantage of the client GPU. In addition the map view uses a variety of public OGC web map services as backgrounds. The selected background images are actually provided by OGC WMS sites and updated in the WPF client as the view changes with zoom and pan gestures. WPF partial trust Xbap applications are restricted to originating server resources. In order to take advantage of all the public image data behind WMS services on the internet cloud it is a simple matter to write a Java servlet proxy.This proxy servlet takes view parameters from the WPF client and posts them off in proper format to a WMS service. The resulting bitmap stream is then asynchronously loaded as a WPF image in the client view.

In this simple case the world of public map atlases becomes part of the application interface using a single xbap client and a Java proxy servlet. The resulting browser app runs more like a local application than a browser app but has the advantage of access to multiple world wide map and image services.

Once a map view is adjusted to the user’s satisfaction a tab change to ‘filters’ allows a user to set up different track sorting algorithms. Filter parameters are adjusted visually with WPF tools in the tab control. Once the parameters are set a filter button triggers an upload to the server where a filter grouping algorithm is triggered to go through the stored GMTI track points and identify tracks based on sequential spatial proximity and timestamps. Once the algorithm completes its pass through the selected GMTI mission, the user can choose to display the results in tabular or vector format.

AJAX is again handling the resource communication between client and server. Parameters from the interface flow to the server while results flow back to the client. However, in this case there are two entirely different worlds talking to each other, WPF C# on the client and Apache Java on the server. This magic is possible because of the decoupling provided by XML. XML parameter files are sent to java servlets which in turn respond with Xaml XML results to the C# client. This magic is greatly helped by two .NET classes XamlReader and XamlWriter. Using XamlWriter.Save on a WPF object serializes to an XML text that can be sent to the server. The return trip result can be picked up with the inverse XamlReader.Load to parse the response XML text into a WPF object.                          

StringReader stringReader = new StringReader(responseFromServer);
XmlReader xmlReader = XmlReader.Create(stringReader);
Canvas geom = (Canvas)XamlReader.Load(xmlReader);
canv.Children.Add(geom);
canv.RegisterName(geom.Name, geom);

The Xbap client does not care how the Xaml is created and the Java servlet does not care either, which lets two very distinct worlds talk to each other. This is very nice for the developer who can take advantage of high performance Microsoft WPF client interface controls and at the same time use a Linux based virtual servers as EC2 instances.


Fig 2 WPF pan zoom and scroll handled by local client C# and Imagery background from OWS services


Fig 3 XML bridges makes it possible to have Java filters feed to WPF geometries in the map view


Fig 4 Imagery backgrounds are interchangeable and vector geometries include event listeners for rollover and select