Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
F#, ServiceStack + Project Service
open System
open ServiceStack.ServiceHost
open ServiceStack.WebHost.Endpoints
open ServiceStack.ServiceInterface
type Project() =
let mutable projectID = 0
let mutable projectName = ""
let mutable companyName = ""
let mutable projectStatus = ""
member this.ProjectID with get() = projectID and set(pid) = projectID <-pid
member this.ProjectName with get() = projectName and set(pn) = projectName <- pn
member this.CompanyName with get() = companyName and set(cn) = companyName <- cn
member this.ProjectStatus with get() = projectStatus and set(ps) = projectStatus <-ps
type ProjectResponse() =
let mutable projects = List.empty<Project>
member this.Projects with get() = projects and set(pr) = projects <- pr
type ProjectRequest() =
let mutable projectName = ""
interface IReturn<ProjectResponse>
member this.ProjectName
with get() = projectName
and set(n) = projectName <- n
type ProjectService() =
inherit Service()
member this.Any (request:ProjectRequest) =
Projects = [Project(ProjectName=request.ProjectName, ProjectID=1, CompanyName="A")])
//Define the Web Services AppHost
type AppHost() =
inherit AppHostHttpListenerBase("Project F# Services", typeof<ProjectService>.Assembly)
override this.Configure container = ignore()
//Run it!
let main args =
let host = if args.Length = 0 then "http://*:8080/" else args.[0]
printfn "listening on %s ..." host
let appHost = new AppHost()
appHost.Start host
Console.ReadLine() |> ignore
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment