wcf demo in Boo

This is the promised simple wcf demo in boo.

It is based upon the examples in Learning WCF by Michelle Leroux Bustemante.

### Contract.boo ###
namespace IndigoService

import System.ServiceModel

[ServiceContract(Namespace:”http://foo/bar”)]
interface IHelloIndigoService:
    [OperationContract]
    def SayHello() as string:
        pass

### Service.boo ###
namespace IndigoService

#import System.ServiceModel
   
class HelloIndigoService(IHelloIndigoService):
    def SayHello() as string:
        return “Hello Indigo”

### Host.boo ###
namespace IndigoService

import System.ServiceModel
import System

host = ServiceHost(typeof(IndigoService.HelloIndigoService), Uri(“http://localhost:8000/HelloIndigo”))
host.AddServiceEndpoint(typeof(IndigoService.IHelloIndigoService), BasicHttpBinding(), “HelloIndigoService”);
host.Open();
print “Press any key to terminate”
Console.ReadKey()

### Client.boo ###
namespace IndigoService

import System
import System.ServiceModel

try:
    ep = EndpointAddress(“http://localhost:8000/HelloIndigo/HelloIndigoService”)
    proxy as IHelloIndigoService
    proxy = (ChannelFactory [of IHelloIndigoService]).CreateChannel(BasicHttpBinding(),ep)
    Console.WriteLine(proxy.SayHello())
    Console.ReadKey()
except e:
    print “Problem with server – probably not there”
    # print e

### default.build ###
<?xml version=”1.0″ ?>

<project name=”wcfdemo” default=”build”>
<property name=”boo.dir” value=”C:/boo/bin” />
    <target name=”build” depends=”wcfserver,wcfclient” />
    <target name=”wcfserver”>
        <loadtasks assembly=”${boo.dir}/Boo.NAnt.Tasks.dll” />
                 <booc output=”wcfserver.exe” target=”exe”>
            <references>
                <include name=”C:/Program Files/Reference Assemblies/Microsoft/Framework/v3.0/*.dll” />
            </references>
            <sources>
                <include name=”Service.boo” />
                <include name=”Host.boo” />
                <include name=”Contract.boo” />               
            </sources>
        </booc>
    </target>
    <target name=”wcfclient”>
        <loadtasks assembly=”${boo.dir}/Boo.NAnt.Tasks.dll” />
                 <booc output=”wcfclient.exe” target=”exe”>
            <references>
                <include name=”C:/Program Files/Reference Assemblies/Microsoft/Framework/v3.0/*.dll” />
            </references>
            <sources>
                <include name=”Client.boo” />
                <include name=”Contract.boo” />               
            </sources>
        </booc>
    </target>
</project>

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s