A WCF Service from IronPython

Windows Communication Foundation (WCF) is part of .NET 3 and makes creating and interacting with web services from C# substantially easier. WCF makes extensive use of .NET attributes, making it difficult to use from IronPython versions before 2.6 without wrapping the use of attributes in some C#.

IronPython 2.6 brings in support for attributes through the __clrtype__ metaclass. It doesn't yet allow you to create a .NET interface from pure Python code (although you can implement existing interfaces just by inheriting from them), so *some* C# is still needed for full use of WCF with IronPython 2.6. The dynamic languages team are looking at ways that __clrtype__ could be extended to allow the creation of interfaces in a future release.

In his latest blog post Lukáš Čenovský demonstrates how to create a WCF service from C# and then shows the same code from IronPython, along with the minimal C# still needed.
Until IronPython 2.6, it was not possible to create WCF service host in pure IronPython. The closest way was to create stub in C# and subclass it in IronPython or create the whole service in C# and run it from IronPython. It is now much simpler with IronPython 2.6 although you still have to write a little C# code.

Comments

  1. Looks like it will be possible to create WCF service in pure IronPython without any C# - see this checkin where there is a comment:

    Changeset Id: 1258596
    Date: 11/6/2009 2:16:40 PM

    (sborde) Adds support to declare intefaces in the clrtype sample

    ReplyDelete

Post a Comment

Popular posts from this blog

Extending Abobe Flash Player and AIR with Python and Ruby

Should Python Projects Support IronPython and Jython?

Further Adventures of the Debugger