Sunday, June 13, 2010

The Standard WCF Service Application Template for F#

In the interest of building up a larger set of installed templates for F#, I've ported the standard C# WCF Service Application to F# and packaged it into a .vsi file.

Here are a few snippets from the solution that the template creates:

namespace FSharpWcfServiceApplicationTemplate.Contracts

open System.Runtime.Serialization
open System.ServiceModel

type IService1 =
    abstract GetData: value:int -> string
    abstract GetDataUsingDataContract: composite:CompositeType -> CompositeType
namespace FSharpWcfServiceApplicationTemplate

open System
open FSharpWcfServiceApplicationTemplate.Contracts 

type Service1() =
    interface IService1 with
        member x.GetData value =
            sprintf "%A" value
        member x.GetDataUsingDataContract composite =
            match composite.BoolValue with
            | true -> composite.StringValue <- 
                          sprintf "%A%A" composite.StringValue "Suffix"
            | _ -> "do nothing" |> ignore
You can download the installer from here and get the full source from

No comments:

Post a Comment