import clr import clrtype clr.AddReference('System.ServiceModel') clr.AddReference('TestServiceInterface') from TestServiceInterface import ImyService from System import Console, Uri from System.ServiceModel import (ServiceHost, BasicHttpBinding, ServiceBehaviorAttribute, InstanceContextMode) ServiceBehavior = clrtype.attribute(ServiceBehaviorAttribute) class myService(ImyService): __metaclass__ = clrtype.ClrMetaclass _clrnamespace = "myWcfService" _clrclassattribs = [ ServiceBehavior(InstanceContextMode=InstanceContextMode.Single)] def GetData(self, value): return "IronPython: You entered: %s" % value sh = ServiceHost( myService(), Uri("http://localhost:9000/myWcfService") ) sh.AddServiceEndpoint( clr.GetClrType(ImyService), BasicHttpBinding(), "") sh.Open() Console.WriteLine("Press to terminate\n") Console.ReadLine() sh.Close()