Writing an IronPython WCF Host
This is a simple WCF host written in IronPython that consumes a library I wrote in C#.
import clr
clr.AddReferenceByPartialName("System.ServiceModel")
clr.AddReferenceByPartialName("CSharpClass")
from System.ServiceModel import ServiceHost, BasicHttpBinding
from System.ServiceModel.Description import ServiceMetadataBehavior
from CSharpClass import PersonService, IPersonService
from System import Array, Uri
uri = Uri("http://localhost:1234/people")
uriArray = Array[Uri]([uri]) # creates a generic array of type Uri
serviceHost = ServiceHost(PersonService, uriArray)
binding = BasicHttpBinding()
serviceHost.AddServiceEndpoint(IPersonService, binding, "http://localhost:1234/people")
behavior = ServiceMetadataBehavior()
behavior.HttpGetEnabled = True
serviceHost.Description.Behaviors.Add(behavior)
serviceHost.Open()
raw_input("Service has been started. Press Enter to exit...")
Labels: .NET, IronPython, WCF






1 Comments:
You can now implement the WCF service in IronPython and have only the interface in C# - see my blog post.
By
Lukáš Čenovský, at Fri Oct 30, 10:45:00 AM
Post a Comment
<< Home