views:

68

answers:

2

I was curious how anyone would go about creating WCF based services using a dynamic language like IronPython or IronRuby. These languages do not have the concept of interfaces. How would someone define service contracts? Would we need to rely on static languages for such kind of tasks? I am a big fan of Python in particular and would like to know if this can be done at this point.

+2  A: 

IronPython has a new feature in 2.6 to create normal .NET classes using the Python class definition machinery. The new feature is enabled by overriding clrtype on a metaclass. You can then declare a class with a bunch of decorators and the metaclass creates a new .NET type. As a sample we have the set of metaclasses which can be used (or customized) over on the IronPython CodePlex site for the 2.6.1 release.

I haven't tried it w/ WCF in particular but it does work in other cases when you need to use a static type. There are some cases where it won't work - particularly if the framework needs to do Type.GetType(typeName).

Dino Viehland
+2  A: 

I have done some experiments - see my experiences on my blog.

The good news is WCF service can be fully written in IronPython. The bad news is such WCF service does not work in IIS because you cannot use compiled IronPython code from C# or VB directly.

Lukas Cenovsky
"you cannot use compiled IronPython code from C# or VB directly" i dont quite understand this part
Perpetualcoder
When you compile IronPython code with `pyc.py`, it actually does not compile the code in the sense as C# or VB do. It produces mangled IL which cannot be represented with CLS compliant IL (see http://blogs.msdn.com/shrib/archive/2008/07/24/cls-compilation-of-ironpython.aspx for details). If you check the produced .dll with Reflector, you will see what I mean.
Lukas Cenovsky